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

Maximize Efficiency When Getting Character from GUIs?

Instead of having to do

script.Parent.Parent.Parent.Parent.Character

in a gui to get the player, is there another method which is more efficient?

1 comment

0

This is in a server script so I cannot do game.Players.LocalPlayer

1 answer

✓ Accepted answer

All scripts in the PlayerGui should be local, so therefore you can use LocalPlayer.

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()

plr.CharacterAdded:Wait(): This will make sure the character has loaded.

2 comments

0

He mentioned he wants it in a Server Sided Script

1

I mention he shouldn't use a Regular Script in PlayerGui/StarterGui.

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