So I have a TextLabel that changes the text every few seconds and I am trying to make a Frame that becomes visible when the text in TextLabel says a certain thing. Script for the Frame:
if game.StarterGui.ScreenGui.TextLabel.Text == ¨Text¨ then script.Parent.Visible = true -- Frame end
Anyone know where I went wrong here?
You're using StarterGui. If you want things to update immediately, use PlayerGui.
local playergui = game.Players.LocalPlayer:WaitForChild("PlayerGui") if playergui.ScreenGui.TextLabel.Text == "Text" then script.Parent.Visible = true end
Its likely because you are trying to use StarterGui instead of PlayerGui. I don't believe code is executed in StarterGui and it wouldn't align with the client anyway.
Do this instead.
if game.Players.LocalPlayer.PlayerGui.ScreenGui.TextLabel.Text == ¨Text¨ then script.Parent.Visible = true -- Frame end
I think it's because on line 3 you didn't reference the object that is being called the changing line 3 with also playergui is more efficient than startergui also playergui is for clients whereas startergui is for GUIs Another reason why this won't work is because things such as text requires data like tostring and tonumber
local playergui = game.Players.LocalPlayer:WaitForChild("PlayerGui") if playergui.ScreenGui.TextLabel.Text == "Text" then script.Parent.Frame.Visible = not script.Parent.Frame.Visible end