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

Help with finding textlabel in playergui?

I wanted this to work but there is only 1 line preventing this.

local plr = game.Players.LocalPlayer
local plrgui = plr.PlayerGui
local label = plrgui:FindFirstChild("Testing").Title
local wall = game.Workspace.BrickWall

function Round(Number, Decimals)
	Decimals = (Decimals > 0 and Decimals or 0)
	Number = Number*(10^Decimals)
	local rNum, Dec = math.modf(Number)
	if Dec >= .5 then
		rNum = rNum + 1
	end
	return rNum/(10^Decimals)
end

while wait(.001) do
local magnitude = (plr.Character.Torso.Position - wall.Position).magnitude
label.Text = "Current Distance From Brick Wall: "..Round(magnitude,1)
end

Error: Players.Player.PlayerGui.Magitude Script:3: attempt to index a nil value Help?

3 comments

0

The error is on line 3, so line is is the label value. Make sure that you have the correct order and it is in the right heirachy

0

it is

0

Well then something must be missing. Either this isn't the right script, or you just add :WaitForChild

1 answer

✓ Accepted answer

Do you need it to be available as soon as possible? Then add a WaitForChild() function

local plr = game.Players.LocalPlayer
local plrgui = plr.PlayerGui
local label = plrgui:WaitForChild("Testing").Title
local wall = game.Workspace.BrickWall

etc...

If you only need it to work, then add a simple wait() to the top

wait(1)
local plr = game.Players.LocalPlayer
local plrgui = plr.StarterGui
local label = plrgui["Testing"].Title
local wall = game.Workspace.BrickWall

etc...

If anything does not work just comment below and I will fix it

TheArmoredReaper

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