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

I'm trying to get this tool to be able to reset my character.. Help?

I am following the cookbook to scripting on the ROBLOX wikia. And I'm on chapter 5 at the beginning where you make a hopperbin that resets your character once you left click.. I can't seem to get it to do that.

I have a tool that is in StarterPack and the localscript is inside the tool.

This is the code:

script.Parent.Selected:connect(function(m)
	m.Button1Down:connect(function()
		if game.Players.LocalPlayer.Character then
			game.Players.LocalPlayer.Character:BreakJoints()
		end
	end)
end)

This is the error: Selected is not a valid member of tool.

1 answer

✓ Accepted answer

Your problem is that Selected is not an event, however Equipped is. Replace Selected with Equipped, and it should work. However, I believe a more convienient way would be to use the activated event like this:

script.Parent.Activated:connect(function()
    if game.Players.LocalPlayer.Character then
        game.Players.LocalPlayer.Character:BreakJoints()
    end
end)

EDIT: Heres the link to the tools page: http://wiki.roblox.com/index.php?title=API:Class/Tool

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