As the Title Says Lmao.
How to get the Player's Character From a serverScript?
3 answers
There's a few methods
From a ClickDetector:
workspace.Part.ClickDetector.MouseClick:connect(function(plr)
local char = plr.Character
--Do whatever
end)
From a Touched Event:
workspace.Part.Touched:connect(function(hit)
if game.Players:GetPlayerFromCharacter(hit.Parent) then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
local char = plr.Character
--Do whatever
end
end)
Grabbing it on the player joining the game:
game.Players.PlayerAdded:connect(function(plr)
repeat wait() until plr.Character
local char = plr.Character
--Do whatever
end)
Or if you know the players name:
local char = workspace['Player1']
Here are some links to some helpful wiki articles:
https://developer.roblox.com/en-us/api-reference/class/ClickDetector
https://developer.roblox.com/en-us/api-reference/event/Players/PlayerAdded
https://developer.roblox.com/en-us/api-reference/event/BasePart/Touched
2 comments
Rep+ for adding links(and overall quality of answer), uncommon to see people adding links.
^ Thanks :)
game.Players."PlayerName".Character This points to the character of the "PlayerName"
so you can do something like this (I will be the example):
local player = game.Players.Rafii2198.Character
player.Humanoid.NameDisplayDistance = 55
player.HumanoidRootPart.Position = player.HumanoidRootPart.Position + Vector3.new(0,10,0)
This will change the distance that other players will see my name to 55 (default is 100) and move me 10 studs up.
1 comment
Everything about that is on Roblox Developer site https://developer.roblox.com/en-us/api-reference/class/Player
Player has a property called Character. Indexing this property will return the player's associated character.
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
Player.Character ...?
@qChaos Player is = game.players.localPlayer ?
You can't access LocalPlayer from a server script