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

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

Asked by 10 years ago

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.

0
Yes, I know I don't have to do "16+16", but I wanna be different. Lol. alphawolvess 1784 — 10y

2 answers

Log in to vote
1
Answered by 10 years ago

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
Ad
Log in to vote
1
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
10 years ago

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)
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 alphawolvess 1784 — 10y

Answer this question