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

How to make player speed increase on Select?[Still Not solved! Help!]

I am using a HopperBin.

SP = script.Parent
walkspeed = script.Parent.Players.LocalPlayer.Humanoid.WalkSpeed

SP.Selected:connect(function()
	if walkspeed == 16 then 
		walkspeed = 16+16
	end
end)

My problem is I don't know how to change my directory to my player or the LocalPlayer using the tool. If I can find out how to get to my player I can pretty much do the rest and find out and figure out any other errors. Is LocalPlayer usable to find my in-game character? I searched in Wiki and I think theres something about Player...Idk.

1 comment

0

Yes, I know I don't have to do "16+16", but I wanna be different. Lol.

2 answers

There are a few issues here... First off, the Humanoid is in the Character, not the Player, so it would be:

Humanoid = game.Players.LocalPlayer.Character.Humanoid

Also, WalkSpeed is a property of the Humanoid, so it can not be a variable, you would have to do:

if Humanoid.WalkSpeed == 16 then
-- Code here
end

LocalPlayer is the Player object, not the Character Model.

You can use the Character property of Player to get its associated Character model, however.

You are making a classic mistake: when you set a variable to some property, as you are trying to do in line 2 here, the variable holds the value of that property, not a reference to the property! Your code cannot change the WalkSpeed unless it maintains a reference to the Humanoid:

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

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

1 comment

0

I've tried your script and it does not work. The error I get is 01:42:28.392 - Players is not a valid member of HopperBin

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