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

How do I Reference the player in the workspace?

I really need help renferencing the player in the workspace the character model with all the body parts and shirts and stuff in it i was thinking game.workspace.player.name or a variable of player.name but that doesnt work and im very stumped at this point if u have any way to referecning PLEASE TELL ME my discord is bily117#5405 add me and dm me my dms are always open

1 comment

0

Player event. Here's an article from the dev hub: https://developer.roblox.com/en-us/api-reference/event/Players/PlayerAdded

2 answers

✓ Accepted answer

The player in workspace is called the character. You can simply get the character by adding .Character after the player

game.Players.LocalPlayer -- This is the player
game.Players.LocalPlayer.Character -- This is the Character of the LocalPlayer

I think you're looking for the GetPlayerFromCharacter() function. To get the player's instance from a character, you'd use GetPlayerFromCharacter()

local Players = game:GetService("Players")

local workspaceCharacter = game.Workspace:FindFirstChild("player name goes here")

local player
if workspaceCharacter ~= nil then
	player = Players:GetPlayerFromCharacter(workspaceCharacter)
else
	print("not a valid character model.")
	player = nil
end

https://developer.roblox.com/en-us/api-reference/function/Players/GetPlayerFromCharacter

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