Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 8 years ago

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

Log in to vote
3
Answered by 8 years ago
Edited 8 years ago

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

Ad

Answer this question