I need this to be on touch so when someone touches a part it will activate the script.
function onChildEntered(child) if game.Players:findFirstChild(child.Name) then if child:findFirstChild("Animate") then child.Animate:remove() end end end game.Workspace.ChildAdded:connect(onChildEntered)
What CodeTheorem said, but it'd look more like this:
script.Parent.Touched:connect(function(hit) local plr = Game:GetService("Players"):GetPlayerFromCharacter(hit.Parent) local anim = hit.Parent:FindFirstChild("Animate") if plr and anim then anim:Destroy() end end)
You just have to change the Event
that you are handling
. Here's an example:
script.Parent.Touched:connect(function(hit) if game.Players:findFirstChild(hit.Name) then if hit:findFirstChild("Animate") then hit.Animate:remove() end end end)