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

Why isn't my speed script working?

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

✓ Accepted answer

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)

2 comments

0

Can you show me a script like this but instead of changing walk speed it made you jump higher?

0

I can send you a little tutorial on gravity https://www.youtube.com/watch?v=rT72n5_eLlU

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.

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