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

Text Change On tool Equip?

Asked by 8 years ago

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)

0
Is this the full script? Vezious 310 — 8y

2 answers

Log in to vote
1
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
8 years ago

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.

0
Thanks alot this Helps alot! TayLife12 69 — 8y
Ad
Log in to vote
-1
Answered by 8 years ago

.Toolname.text.Text = "TOOl2"

Answer this question