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

Speed Script Nonfunctioning?

Asked by 9 years ago

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

01repeat wait() until game.Players.LocalPlayer
02player = game.Players.LocalPlayer
03 
04repeat wait() until player.Character
05character = player.Character
06 
07repeat wait() until character:FindFirstChild("Humanoid")
08humanoid = character.Humanoid
09 
10humanoid.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 9 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:

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

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 — 9y
Ad
Log in to vote
0
Answered by
adatax 5
9 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

01repeat wait() until game.Players.LocalPlayer
02player = game.Players.LocalPlayer
03 
04repeat wait() until player.Character
05character = player.Character
06 
07repeat wait() until character:FindFirstChild("Humanoid")
08humanoid = character.Humanoid
09 
10character.Humanoid.WalkSpeed = 25 -- set walkspeed

Hope this helps

Answer this question