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

Maximize Efficiency When Getting Character from GUIs?

Asked by
INOOBE_YT 387 Moderation Voter
7 years ago

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?

0
This is in a server script so I cannot do game.Players.LocalPlayer INOOBE_YT 387 — 7y

1 answer

Log in to vote
1
Answered by 7 years ago

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.

0
He mentioned he wants it in a Server Sided Script AstrealDev 728 — 7y
1
I mention he shouldn't use a Regular Script in PlayerGui/StarterGui. OldPalHappy 1477 — 7y
Ad

Answer this question