Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can I make this onTouch?

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)

2 answers

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.