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

Why isn't my speed script working?

Asked by 9 years ago

I tried making a script that changes the players speed but it is not working and there is no error in Output

script.Parent.ClickDetector.MouseClick:connect(function(hit)
    local humanoid = hit.Parent:findFirstChild("Humanoid")
    if humanoid~=nil then
        wait(0.01)
        humanoid.WalkSpeed = 150
    end
end)

2 answers

Log in to vote
1
Answered by 9 years ago

that is because the ClickDetector.MouseClick takes the argument of the player i believe sorry if i am wrong. You can access the character by doing player.Character.

script.Parent.ClickDetector.MouseClick:connect(function(player)
   local humanoid=player.Character:findFirstChild("Humanoid")
    if  humanoid~=nil then
        wait(0.01)
        humanoid.WalkSpeed = 150
    end
end)

0
Can you show me a script like this but instead of changing walk speed it made you jump higher? LordZerefu 30 — 9y
0
I can send you a little tutorial on gravity https://www.youtube.com/watch?v=rT72n5_eLlU threatboy101 2 — 9y
Ad
Log in to vote
0
Answered by
yumtaste 476 Moderation Voter
9 years ago

When the MouseClick event fires, it returns the player that clicked, in your case, you named it "hit". I would change it to "player" so it's not confusing. Also, since the event returns a player, line 2 is looking for a Humanoid in the Players service. Just replace line 2 with local humanoid = player.Character.Humanoid. Note that I used "player" instead of "hit," since I recommended changing the variable name.

Answer this question