What are the differences in Local player, Player, and Character?

Can I get an explanation on the differences between: Local Player, Player and Character?

I thought they were the same until I was following a script which had this:

game.Players.LocalPlayer.Character:Waitforchild (“Humanoid”).Walkspeed = 0

I know this is simple but I’m still a beginner to scripting, and I’ve had been holding this question for a while.

8 Likes

LocalPlayer is only available to be used by LocalScripts and it is the Player instance that belongs to that Client. Attempting to use this in server scripts will return nil

Character is a property of LocalPlayer and it is the model of the Player in the workspace, it can be nil if the Character isn’t loaded

I’m not sure what you mean by Player, you mean the return of PlayerAdded?

2 Likes

LocalPlayer is a property, the Roblox object being referred to by it is a Player object.

1 Like

I meant Local Player because I saw it in the script.

They answered that: Players.LocalPlayer is the specific Player object associated with a given client. The property is nil on the Server (i.e. normal Scripts) because the Server has no associated Played.

1 Like

Then basically to answer that, it’s basically what I had mentioned, it’s a property of the Players service that returns the player instance of a client or nil if it is being used in a server script

1 Like

(apologies, I use “he/him” as my default pronouns, especially when I’m too tired to think about it.)

Soo in the end what’s the diffrence beween it and player and character? I didn’t understand your definition of local player as I don’t know what a client is and don’t have a good grasp on severs…

You should give this article a read, it goes over what we mean by Client and Server.

2 Likes

A client is a user that is playing on your game basically, again, LocalPlayer returns the Player of a user that the LocalScript is related to, and Character is a property of the Player instance that returns the Model of them in the workspace, example

  • I have a localscript in me
  • That localscript gets LocalPlayer, which gets my Player instance
  • It then gets my character/model that is in the workspace via the Character property
  • It then removes all my speed

That’s basically how

game.Players.LocalPlayer.Character:Waitforchild (“Humanoid”).Walkspeed = 0

works, it gets your player instance, gets the model of you from the workspace, gets the humanoid from that model, and sets its walkspeed to 0

8 Likes

I’ll be looking into this as just by reading the first sentence I can tell it will be a clear explanation. thanks

Everything I needed. Thanks for explaining the script too.

1 Like

Anytime! If you have anymore issues don’t be afraid to make another post!

2 Likes

local player can only be used in local scripts

2 Likes