A problem with gui

Hello everyone. I wanted to make it so that if “value1” was true, the text of the gui was :white_check_mark:, and otherwise it is false, the text will be :x:, but in response the text does not change at all.

Code:

local owns = game.ReplicatedStorage.Achievements.Test
while true do
	wait(1)
	if owns.Value == true then
		local prt = script.Parent
		prt.Text = "✅"
		prt.TextColor3 = Color3.new(0.133333, 1, 0)
	else
		local prt = script.Parent
		prt.Text = "❌"
		prt.TextColor3 = Color3.new(1, 0, 0.0156863)
	end
	
end

I made it in script, not localscript

try the changed event instead of looping

if the script is in a screen gui. change it to a local script.
if the script is in a surface gui a normal script will do

In addition you shouldn’t use while true do but instead use changed. Moreover, it’s better to combine the variables prt into one variable.
And you don’t have to write == true, because if you don’t write that part it’s automatically == true for the script.

local owns = game.ReplicatedStorage.Achievements.Test
owns.Changed:Connect(function()
	local prt = script.Parent
	if owns.Value then
		prt.Text = "✅"
		prt.TextColor3 = Color3.new(0.133333, 1, 0)
	else
		prt.Text = "❌"
		prt.TextColor3 = Color3.new(1, 0, 0.0156863)
	end
end)
1 Like