Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local clickEvent = game.ReplicatedStorage.RemoteEvents.PlayerClicked
- local shot = false
- clickEvent.OnServerEvent:Connect(function(Player)
- if not shot then
- shot = true
- if script.Parent.Parent.Parent.DriveSeat:FindFirstChild("SeatWeld") ~= nil then
- if script.Parent.Parent.Parent.DriveSeat.SeatWeld.Part1.Parent.Name == Player.Name then
- Speed = 5
- local Tank
- local bin = script.Parent
- local eff = script.Parent.Parent.ShootEffectPart
- local Debris = game:GetService("Debris")
- local explosion = Instance.new("Explosion")
- explosion.BlastRadius = 0
- explosion.BlastPressure = 0
- explosion.Position = bin.CFrame.p
- explosion.Parent = bin
- Debris:AddItem(explosion, 2)
- script.Parent.Sound:Play()
- local blow = Instance.new("BodyThrust")
- blow.Parent = script.Parent.Parent.Parent.Body.Bottom.Bottom
- blow.Force = script.Parent.CFrame.lookVector * 8000
- Debris:AddItem(blow, 0.1)
- local ignore = script.Parent.Parent:GetChildren();
- table.insert(ignore, Tank)
- local Ray = Ray.new(bin.Position, bin.CFrame.LookVector * 8000)
- local Hit,Position = game.Workspace:FindPartOnRayWithIgnoreList(Ray, ignore)
- if Hit then
- if Hit.Parent:FindFirstChild("Humanoid") then
- --Hit.Parent.Humanoid:TakeDamage(100)
- end
- end
- --create raycast
- local RayPart = Instance.new("Part", script.Parent)
- RayPart.Name = "RayPart"
- RayPart.BrickColor = BrickColor.new("Dark stone grey")
- RayPart.Transparency = 0
- RayPart.Anchored = true
- RayPart.CanCollide = false
- RayPart.TopSurface = Enum.SurfaceType.Smooth
- RayPart.BottomSurface = Enum.SurfaceType.Smooth
- RayPart.formFactor = Enum.FormFactor.Custom
- local Distance = (Position - bin.CFrame.p).magnitude
- RayPart.Size = Vector3.new(1,1,7)
- RayPart.CFrame = CFrame.new(Position, bin.CFrame.p) * CFrame.new(0,0,-Distance + 2.5)
- local RayPartMesh = Instance.new("BlockMesh", RayPart)
- game.Debris:AddItem(RayPart, Distance/Speed)
- --create bullet
- coroutine.resume(coroutine.create(function()
- local RayPart = RayPart
- local RayPartMesh = RayPartMesh
- local Distance = Distance
- for i = 1, Distance/Speed do
- if RayPart then
- wait()
- RayPartMesh.Offset = RayPartMesh.Offset + Vector3.new(0, 0, Speed)
- end
- end
- if RayPart then
- wait(1)
- RayPart:Destroy()
- print(RayPart.Position)
- --explosion at hit???
- local position = RayPart.CFrame.p
- local explosion2 = Instance.new("Explosion")
- explosion2.BlastRadius = 0
- explosion2.BlastPressure = 5000
- explosion2.Position = RayPart.CFrame.p
- explosion2.Parent = RayPart
- Debris:AddItem(explosion2, 2)
- --
- end
- end))
- end
- end
- wait(5)
- shot = false
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement