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

How to access the player character from a Local Script?

Asked by 5 years ago

I am trying to access the character model in game.Workspace, but I am not able to accomplish this. How may I do this task?

0
game.Players.LocalPlayer.Character OBenjOne 190 — 5y
0
workspace:WaitForChild(game.Players.LocalPlayer.Name); Kappa Fifkee 2017 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

First you need to get the player

local player = game.Players.LocalPlayer

and then you get the character

local character = player.Character or player.CharacterAdded:Wait()

You need to use CharacterAdded:Wait() to make the script wait until the character is loaded. If you don't do it then the character variable may be nil.

0
Aight man, thanks, I tried this many times and made adjustments but it didn't work, I'll try it this way MasonJames136 21 — 5y
0
Aight thanks man, this worked. MasonJames136 21 — 5y
Ad

Answer this question