So I created a (local)script that places a billboard GUI above your head with some text on it. The problem is, you can only see your billboard GUI and no one else's due to it being placed in a localscript.
I'm pretty sure everything in the script is regular script compatible, but this one line of code is blocking me from placing it in a regular script and I do not know of an alternative for it:
player = game.Players.LocalPlayer
If you'd like to see the script in its entirety:
player = game.Players.LocalPlayer character = player.Character script.Parent.FocusLost:connect(function() local bg = Instance.new("BillboardGui") bg.Parent = character.Head bg.Size = UDim2.new(1, 0, 1, 0) bg.StudsOffset = Vector3.new(0, 2, 0) local frame = Instance.new("Frame") frame.Parent = bg frame.Size = UDim2.new(1, 0, 1, 0) frame.BackgroundTransparency = 1 local text = Instance.new("TextLabel") text.Parent = frame text.Position = UDim2.new(0.25, 0, 0.25, 0) text.Size = UDim2.new(0.5, 0, 0.5, 0) text.Text = script.Parent.Text text.BackgroundTransparency = 1 text.TextColor3 = Color3.new(1, 1, 1) text.Font = "ArialBold" text.FontSize = "Size24" end)
tl;dr: What is a regular script compatible alternative version to LocalPlayer?
The simplest solution is to put the Script inside the Player (PlayerGui or Backpack) (or their character), and then just reference up to the appropriate Parent
.
If we had an object hierarchy like this:
Players Player PlayerGui Frame TextBox Script
Then we would use something like this to refer to that Player
local box = script.Parent; local frame = box.Parent; local gui = frame.Parent; local player = gui.Parent;
Or, in just one line:
local player = script.Parent.Parent.Parent.Parent;
Note that that hierarchy I showed would be analagous to
StarterGui Frame TextBox Script
Since the contents of StarterGui get copied into each PlayerGui.