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

Would this be how i change player's walk speed without PlayerAdded?

Asked by 8 years ago

So err what I'm trying to do is change all of the players walk speed at a certain point, and not player added/player enter. So like after 15 seconds all players walk speed changes. This is what i tried.. :

wait(15)
function (changespeed)
for v_in pairs, do
game.Players.Walkspeed = 0
end

changspeed()

I think it's really wrong that is why i need help :/

1 answer

Log in to vote
5
Answered by 8 years ago
Edited 8 years ago

What you did wrong:

  • You put the function's name in the wrong place, it goes outside of the parenthesis, not inside.
  • You were attempting to loop through nothing - which would break your code.
  • You were attempting to index game.Players as an individual player (it is actually the holder of individual players).
  • The Walkspeed property is not inside the player, it is inside their Character's Humanoid.
  • You attempted to call the function with the wrong name (you made a typo, changspeed was not the name defined, changespeed was).

Code:

wait(15)

function changeSpeed() -- the function's name is defined outside of the parenthesis
    for _,v in pairs (game.Players:GetPlayers()) do -- loops through a table of players
        local char = v.Character -- their character
        if char then -- if their character exists
            char:WaitForChild("Humanoid").Walkspeed = 0 -- Walkspeed may need to be 'WalkSpeed', I can't remember currently
        end
    end
end

changeSpeed()

Hope I helped!

~TDP

0
Also ThatOneKid7590, the reason why the function is capitalized the way it is because that is the standard way programmers name things. You can look up what it is by googling "camelCase" Azmidium 388 — 8y
1
Also, it's WalkSpeed, not Walkspeed. SwardGames 325 — 8y
Ad

Answer this question