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

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

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

✓ Accepted answer
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)


4 comments

0

Finally. Thank you, very much. Now I can move on to more scripting and learning.

0

I edited the script a little for convenience.

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.

0

Okay.

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