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

Text Change On tool Equip?

My Objective here is too make it to where when this tool is Equipped the Text On The Text Label Changes. I have a feeling it has something to do with the Function. Any Help Here? Nothing in Output

Nar = game.StarterGui.Narration.TextLabel
tool = script.Parent

tool.Equipped:connect(function()
	Nar.Text = "Hm, This should work..."
end)

1 comment

0

Is this the full script?

2 answers

✓ Accepted answer

This mistake is made a ton.

StarterGui isn't not what the player sees. It's a container that stores GUIs.

When a player respawns, everything in StarterGui is cloned into their particular PlayerGui.

That's where you need to make your changes, because that's what the player is currently viewing.

You should be using a LocalScript anyways -- the tool will be inside the Player, after all. That means we'll use game.Players.LocalPlayer to access the Player, then access their PlayerGui from there.

local plr = game.Players.LocalPlayer
local plrGui = plr:WaitForChild("PlayerGui")
local tool = script.Parent

tool.Equipped:connect(function()
	local gui = plrGui:WaitForChild("Narration"):WaitForChild("TextLabel")
	gui.Text = "Hm, This should work..."
end)

All the WaitForChilds are probably unnecessary, but I always like to use them in case someone is very laggy, just to try to prevent all possible errors.

1 comment

0

Thanks alot this Helps alot!

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