Mryeetmemes

Paintball

Dec 9th, 2021
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.16 KB | None | 0 0
  1. ball = script.Parent
  2. damage = 15
  3.  
  4.  
  5.  
  6. function onTouched(hit)
  7.     local humanoid = hit.Parent:findFirstChild("Humanoid")
  8. for i=1,3 do
  9. local s = Instance.new("Part")
  10.     s.Shape = 1 -- block
  11.     s.formFactor = 2 -- plate
  12.     s.Size = Vector3.new(1,.4,1)
  13.     s.BrickColor = ball.BrickColor
  14.     local v = Vector3.new(math.random(-1,1), math.random(0,1), math.random(-1,1))
  15.     s.Velocity = 15 * v--15
  16. s.CFrame = CFrame.new(ball.Position + v, v)
  17. ball.BrickCleanup:clone().Parent = s
  18. s.BrickCleanup.Disabled = false
  19.     s.Parent = game.Workspace
  20.  
  21. end
  22.    
  23.  
  24.     if humanoid ~= nil then
  25.         tagHumanoid(humanoid)
  26.         humanoid.Health = humanoid.Health - damage
  27.         wait(2)
  28.         untagHumanoid(humanoid)
  29.     end
  30.  
  31.     connection:disconnect()
  32.     ball.Parent = nil
  33. end
  34.  
  35. function tagHumanoid(humanoid)
  36.     -- todo: make tag expire
  37.     local tag = ball:findFirstChild("creator")
  38.     if tag ~= nil then
  39.         local new_tag = tag:clone()
  40.         new_tag.Parent = humanoid
  41.     end
  42. end
  43.  
  44.  
  45. function untagHumanoid(humanoid)
  46.     if humanoid ~= nil then
  47.         local tag = humanoid:findFirstChild("creator")
  48.         if tag ~= nil then
  49.             tag.Parent = nil
  50.         end
  51.     end
  52. end
  53.  
  54. connection = ball.Touched:connect(onTouched)
  55.  
  56. wait(8)
  57. ball.Parent = nil
  58.  
Advertisement
Add Comment
Please, Sign In to add comment