Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I Reference the player in the workspace?

Asked by 3 years ago

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

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

2 answers

Log in to vote
0
Answered by 3 years ago

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
Ad
Log in to vote
2
Answered by 3 years ago

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

Answer this question