I've seen multiple scripts use the parameter "player" to access the Local Player easily, without need of a local script. I tried to use it myself. But with my luck it didn't work. This is what I tried:
function added(player) player.Character.Humanoid.WalkSpeed = 0 end game.Players.PlayerAdded:connect(added)
Not sure why it didn't work, and every time I test it the output displays either: Workspace.Script:2: attempt to index field 'player' (a nil value) or Workspace.Script:2: attempt to index field 'Character' (a nil value)
I have no idea why it's not working. I thought it might have been just an issue with ROBLOX Studio but to my surprise I inserted takecover's Intro Gui Plugin, a script that uses the "player" parameter, and it worked. Weird how it works in takecover's Plugin, but not my script. Any help would much appreciated. Thanks!
Try this:
function added(player) player.CharacterAdded:connect(function() --Makes sure that the character is loaded in. player.Character.Humanoid.WalkSpeed = 0 end) end game.Players.PlayerAdded:connect(added)
This should work now. The only problem was that the function was firing before the character was loaded in, so you were basically telling the game to go to a nil object. Anyways, if you have any questions or problems, leave a comment below. Hope this helped :P
Locked by Redbullusa and M39a9am3R
This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.
Why was this question closed?