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

Changing speed OnEnter?

Apparently this does not work. It is line 2 with the error.

game.Players.PlayerAdded:connect(function()
	script.Parent.Character.Humanoid.WalkSpeed = 20
end)

F.Y.I the script is in workspace

2 answers

✓ Accepted answer

For this script, you will also want to connect the player added function to the character added function. PlayerAdded will only work on when you first join the game, with the CharacterAdded function, you can reset over and over and still get that speed, plus it's easier to connect to character. For the PlayerAdded function you wanted to define the player, that goes the same with the CharacterAdded function. And script.Parent would not have worked in workspace since there is no speed property for the workspace.

game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(character)
    character.Humanoid.WalkSpeed = 20
end)
end)

You have to wait until the player's character is added to update their WalkSpeed, do the following:

game.Players.PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function(char)
		char.Humanoid.WalkSpeed = 20
	end)
end)

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