Advertisement
Guest User

Untitled

a guest
Dec 10th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.70 KB | None | 0 0
  1. local clickEvent = game.ReplicatedStorage.RemoteEvents.PlayerClicked
  2. local shot = false
  3.  
  4. clickEvent.OnServerEvent:Connect(function(Player)
  5.     if not shot then
  6.     shot = true
  7.     if script.Parent.Parent.Parent.DriveSeat:FindFirstChild("SeatWeld") ~= nil then
  8.     if script.Parent.Parent.Parent.DriveSeat.SeatWeld.Part1.Parent.Name == Player.Name then
  9.         Speed = 5
  10.         local Tank
  11.         local bin = script.Parent
  12.         local eff = script.Parent.Parent.ShootEffectPart
  13.         local Debris = game:GetService("Debris")
  14.         local explosion = Instance.new("Explosion")
  15.         explosion.BlastRadius = 0
  16.         explosion.BlastPressure = 0
  17.         explosion.Position = bin.CFrame.p
  18.         explosion.Parent = bin
  19.         Debris:AddItem(explosion, 2)
  20.         script.Parent.Sound:Play()
  21.        
  22.        
  23.         local blow = Instance.new("BodyThrust")
  24.         blow.Parent = script.Parent.Parent.Parent.Body.Bottom.Bottom
  25.         blow.Force = script.Parent.CFrame.lookVector * 8000
  26.         Debris:AddItem(blow, 0.1)
  27.         local ignore = script.Parent.Parent:GetChildren();
  28.         table.insert(ignore, Tank)
  29.    
  30.         local Ray = Ray.new(bin.Position, bin.CFrame.LookVector * 8000)
  31.         local Hit,Position = game.Workspace:FindPartOnRayWithIgnoreList(Ray, ignore)
  32.             if Hit then
  33.                 if Hit.Parent:FindFirstChild("Humanoid") then
  34.                 --Hit.Parent.Humanoid:TakeDamage(100)
  35.                 end
  36.             end
  37.            
  38.         --create raycast
  39.         local RayPart = Instance.new("Part", script.Parent)
  40.         RayPart.Name = "RayPart"
  41.         RayPart.BrickColor = BrickColor.new("Dark stone grey")
  42.         RayPart.Transparency = 0
  43.         RayPart.Anchored = true
  44.         RayPart.CanCollide = false
  45.         RayPart.TopSurface = Enum.SurfaceType.Smooth
  46.         RayPart.BottomSurface = Enum.SurfaceType.Smooth
  47.         RayPart.formFactor = Enum.FormFactor.Custom
  48.         local Distance = (Position - bin.CFrame.p).magnitude
  49.         RayPart.Size = Vector3.new(1,1,7)
  50.         RayPart.CFrame = CFrame.new(Position, bin.CFrame.p) * CFrame.new(0,0,-Distance + 2.5)
  51.         local RayPartMesh = Instance.new("BlockMesh", RayPart)
  52.         game.Debris:AddItem(RayPart, Distance/Speed)
  53.        
  54.             --create bullet
  55.             coroutine.resume(coroutine.create(function()
  56.             local RayPart = RayPart
  57.             local RayPartMesh = RayPartMesh
  58.             local Distance = Distance
  59.             for i = 1, Distance/Speed do
  60.             if RayPart then
  61.             wait()
  62.             RayPartMesh.Offset = RayPartMesh.Offset + Vector3.new(0, 0, Speed)
  63.             end
  64.             end
  65.                 if RayPart then
  66.                 wait(1)
  67.                 RayPart:Destroy()
  68.                 print(RayPart.Position)
  69.                 --explosion at hit???
  70.                 local position = RayPart.CFrame.p
  71.                 local explosion2 = Instance.new("Explosion")
  72.                 explosion2.BlastRadius = 0
  73.                 explosion2.BlastPressure = 5000
  74.                 explosion2.Position = RayPart.CFrame.p
  75.                 explosion2.Parent = RayPart
  76.                 Debris:AddItem(explosion2, 2)
  77.                 --
  78.                 end
  79.             end))
  80.            
  81.         end
  82.     end
  83.     wait(5)
  84.     shot = false
  85.     end
  86. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement