SebTDZ

Gun

Jul 8th, 2019
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.14 KB | None | 0 0
  1. local Gun = Instance.new("Tool", owner.Backpack)
  2. Gun.Name = "Gun"
  3.  
  4. local P = Instance.new("Part", Gun)
  5. P.Name = "Handle"
  6. P.Size = Vector3.new(1,1,0.1)
  7. P.Transparency = 0
  8. P.BrickColor = BrickColor.new("Bright red")
  9. P.Material = "ForceField"
  10. P.CanCollide = false
  11.  
  12. Gun.Activated:Connect(function()
  13.     local Part = Instance.new("Part", workspace)
  14.     Part.Anchored = true
  15.     Part.CanCollide = false
  16.     Part.BrickColor = BrickColor.new("Bright red")
  17.     Part.Material = "ForceField"
  18.     Part.CFrame = P.CFrame
  19.     Part.Size = Vector3.new(3,3,0.1)
  20.    
  21.     local origin = owner.Character.HumanoidRootPart
  22.     local lookDirection = origin.CFrame.lookVector
  23.     local ray = Ray.new(origin.Position, lookDirection * 500)
  24.     -- Raycast, ignoring the player's character
  25.     local part, hitPosition = workspace:FindPartOnRay(ray, origin.Parent)
  26.     -- Tween
  27.     local Tween = game.TweenService:Create(Part,TweenInfo.new((origin.Position - hitPosition).magnitude /   100,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0), {Position = hitPosition})
  28.     Tween:Play()
  29.    
  30.     wait((origin.Position - hitPosition).magnitude / 100)
  31.    
  32.     if part then
  33.         part:Remove()
  34.     end
  35.     Part:Remove()
  36. end)
Advertisement
Add Comment
Please, Sign In to add comment