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

Speed Script Nonfunctioning?

Asked by 8 years ago

I worked on a speed script and this is what I got:

repeat wait() until game.Players.LocalPlayer
player = game.Players.LocalPlayer

repeat wait() until player.Character
character = player.Character

repeat wait() until character:FindFirstChild("Humanoid")
humanoid = character.Humanoid

humanoid.WalkSpeed = 25 

It keeps the speed at 16 instead of 25. I tested this to be sure I didn't just suck at telling what the speed is by setting it at 150, but that stayed at 16 too.

Any suggestions? Thanks.

2 answers

Log in to vote
0
Answered by 8 years ago

Hi, Instead of doing this, you should use the function PlayerAdded. What this does is fires your code when a player joins. So your code would look like:

game.Players.PlayerAdded:connect(function(player)--Define the player
    repeat wait() until player
    local humanoid = player.Character:FindFirstChild("Humanoid")
    if humanoid and humanoid.Health > 0 then--Check if there is a humanoid and they're alive
        humanoid.WalkSpeed = 25
    end
end)

PlayerAdded function will not work in a local script! Hope this helped!

0
Sorry for the late reply but this worked. Thanks, left an accept. OpticUniversse 50 — 8y
Ad
Log in to vote
0
Answered by
adatax 5
8 years ago

Problem
Im not really sure on this one but simply doing character.humanoid instead of doing through the local made it work.
Solution

repeat wait() until game.Players.LocalPlayer
player = game.Players.LocalPlayer

repeat wait() until player.Character
character = player.Character

repeat wait() until character:FindFirstChild("Humanoid")
humanoid = character.Humanoid

character.Humanoid.WalkSpeed = 25 -- set walkspeed

Hope this helps

Answer this question