I know other ways to substitute for doing this, yet it seems like a simple way of creating what I need.
Let’s say I have a UI in StarterGui, and I place a script inside of a textlabel. Is it non-efficient to use script.Parent.Parent.Parent… (you get it) to try and get the player?
in local script you can use game.Players.LocalPlayer
in script you can use game.Players.PlayerAdded:Connect(function(Player) or script.Parent... -- like what you said
Only local scripts will execute in StarterGui so any of the following ways are valid methods of retrieving the local player.
local player = game.Players.LocalPlayer
local player = game:GetService("Players").LocalPlayer
local player = script:FindFirstAncestorWhichIsA("Player")
local player = script:FindFirstAncestorOfClass("Player")
local player = script:FindFirstAncestorWhichIsA("ScreenGui").Parent.Parent
local player = script:FindFirstAncestorOfClass("ScreenGui").Parent.Parent
The top 2 are always going to be the most efficient.
script.Parent… would only be valid in server scripts if the script is parented to the player/character, if it’s just inside the Workspace/ServerScriptService folder then .Parent will reference those folders (not the player/character).
StarterGui is replicated into the PlayerGui, so I believe it is fine. As for the script not running elsewhere than workspace/SSS, I’m really unsure on that.
That’s because the StarterGui content (including any scripts) is copied into the PlayerGui folder of each player instance each time their character spawns/reloads. It’s ill-advised to use server scripts to handle the the player’s UI as it adds unnecessary strain on the server. The UI need only be relative to the local player and as such should only and always be handled on the client-side through local scripts.
Short Answer: It isn’t Time Efficient and you will Burn Out.
Long Answer
I don’t know if there’s a performance difference, but if there was, it would be next to nothing. It’ll get harder to read your script as you continue to add more .Parent's until eventually, you get lost.
It’s generally good practice to start a variable from an explicit holder of related items. Examples would be: ScreenGui, PlayerInstance, Folder. Pretty much the Main Holder of all your instances of X type or for Y purpose.
Eventually you’re going to have to make changes, and changing 50 of this: script.Parent.Parent.Parent.Parent to script.Parent.Parent.Parent.Parent.Parent for the millionth time will not be fun. Find and Replace might add or remove more .Parent's than you wanted and that brings even more problems.
You’ll burn yourself out if you don’t keep thing easy for yourself.
-- As stated by others, things like this may help you quite a lot when it comes to avoiding script.Parent spam
local ScreenGui = script:FindFirstAncestorOfClass("ScreenGui")