ball = script.Parent damage = 10 r = game:service("RunService") last_sound_time = r.Stepped:wait() function onTouched(hit) local now = r.Stepped:wait() if (now - last_sound_time > .1) then ball.Boing:play() last_sound_time = now else return end local humanoid = hit.Parent:findFirstChild("Humanoid") local zombie = hit.Parent:findFirstChild("Zombie") if humanoid~=nil then tagHumanoid(humanoid) humanoid.Health = humanoid.Health - damage wait(2) untagHumanoid(humanoid) connection:disconnect() else damage = damage / 5 if damage < 2 then connection:disconnect() end end end function tagHumanoid(humanoid) -- todo: make tag expire local tag = ball:findFirstChild("creator") if tag ~= nil then local new_tag = tag:clone() new_tag.Parent = humanoid end end function tagZombie(zombie) -- todo: make tag expire local tag = ball:findFirstChild("creator") if tag ~= nil then local new_tag = tag:clone() new_tag.Parent = zombie end end function untagHumanoid(humanoid) if humanoid ~= nil then local tag = humanoid:findFirstChild("creator") if tag ~= nil then tag.Parent = nil end end end connection = ball.Touched:connect(onTouched) t, s = r.Stepped:wait() d = t + 5.0 - s while t < d do t = r.Stepped:wait() end ball.Parent = nil
Line of error: connection = ball.Touched:connect(onTouched)
Not exactly sure whats wrong with it so if you can tell me how to fix it and explain why the error happens, that would be nice of you.
This means that your script is a child of a tool, and by setting ball to script.Parent you are reffering to that tool. You need to change that line or place your script inside a part. Here is an explaination of what you might be doing wrong