I have asked a question about how to fix my HopperBin which would change speed on selected. I was given 2 answers of which didn't work, then no one started answering so I deleted after 2-3 days of leaving it there and changing title. So now i'm just wondering how can I find the player who is using the tools, body? Example- finding "alphawovless" in Workspace. Here's the "fixed" script I was given.
1 | SP = script.Parent |
2 | humanoid = script.Parent.Players.LocalPlayer.Character.Humanoid |
3 |
4 | SP.Selected:connect( function () |
5 | if humanoid.WalkSpeed = = 16 then |
6 | humanoid.WalkSpeed = 32 |
7 | end |
8 | end ) |
Please help? Make sure the script works before you tell me it and why that works instead before posting it...
1 | SP = script.Parent |
2 | humanoid = game.Players.LocalPlayer.Character.Humanoid --This only works in a LOCAL SCRIPT |
3 |
4 | SP.Selected:connect( function () |
5 | if humanoid.WalkSpeed = = 16 then |
6 | humanoid.WalkSpeed = 32 |
7 | end |
8 | end ) |
Make sure the script is a local script. More on LocalPlayer.
You might want to change this script so if they deselect it they don't stay "running".
01 | SP = script.Parent |
02 | humanoid = game.Players.LocalPlayer.Character.Humanoid |
03 |
04 | SP.Selected:connect( function () |
05 | if humanoid.WalkSpeed = = 16 then |
06 | humanoid.WalkSpeed = 32 |
07 | end |
08 | end ) |
09 |
10 | SP.Deselected:connect( function () |
11 | if humanoid.WalkSpeed = = 32 then |
12 | humanoid.WalkSpeed = 16 |
13 | end |
14 | end ) |