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

Finding the user of a HopperBin's character?[Answered]

Asked by 10 years ago

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.

SP = script.Parent
humanoid = script.Parent.Players.LocalPlayer.Character.Humanoid

SP.Selected:connect(function()
    if humanoid.WalkSpeed == 16 then 
        humanoid.WalkSpeed = 32
    end
end)

Please help? Make sure the script works before you tell me it and why that works instead before posting it...

1 answer

Log in to vote
1
Answered by 10 years ago
SP = script.Parent
humanoid = game.Players.LocalPlayer.Character.Humanoid --This only works in a LOCAL SCRIPT

SP.Selected:connect(function()
    if humanoid.WalkSpeed == 16 then 
        humanoid.WalkSpeed = 32
    end
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".

SP = script.Parent
humanoid = game.Players.LocalPlayer.Character.Humanoid

SP.Selected:connect(function()
    if humanoid.WalkSpeed == 16 then 
        humanoid.WalkSpeed = 32
    end
end)

SP.Deselected:connect(function()
    if humanoid.WalkSpeed == 32 then 
        humanoid.WalkSpeed = 16
    end
end)


0
Finally. Thank you, very much. Now I can move on to more scripting and learning. alphawolvess 1784 — 10y
0
I edited the script a little for convenience. EzraNehemiah_TF2 3552 — 10y
0
I see what you mean. Although, I'm going to name the HopperBin "Run/Walk" so Selecting it will make you run then selecting it again will make you walk. alphawolvess 1784 — 10y
0
Okay. EzraNehemiah_TF2 3552 — 10y
Ad

Answer this question