Changing the text of a Surface text depending on a value

Ok, this code is simple, but it doesn’t work.
I checked everything : the path, the value, the code but it doesn’t change the text, here it is :

local text = script.Parent
local val = script.Parent.Parent.Parent.Parent.Handle.On
local value = script.Parent.Parent.Parent.Parent.Handle.On.Value

val.Changed:Connect(function()
	if value == 0 then
		text.Text = "Ready"
		text.TextColor3 = Color3.new(0, 122, 0)
	elseif value >= 1 then
		text.Text = value
		text.TextColor3 = Color3.new(122,0,0)
	end
end)

Try this instead:

local text = script.Parent
local val = script.Parent.Parent.Parent.Parent.Handle.On

val.Changed:Connect(function()
	if val.Value == 0 then
		text.Text = "Ready"
		text.TextColor3 = Color3.new(0, 122, 0)
	elseif val.Value >= 1 then
		text.Text = val.Value
		text.TextColor3 = Color3.new(122,0,0)
	end
end)

The main reason why it’s not changing I believe is because you only defined the value variable once, so it’ll only keep changing to that 1 String

It’s still not changing, it’s so weird…

Try it again I think I did a mistypo

Shouldn’t we change the
local val = script.Parent.Parent.Parent.Parent.Handle.On to
local val = script.Parent.Parent.Parent.Parent.Handle.On.Value?

This is weird, still not working,
Imma see what the output says

Btw value isn’t defined
So I changed to val.Value but still not

Ok yeah I rushed that one Add print statements as well if for some reason it doesn’t work, but try it once more unless if you saw the mistakes

Note that the color change
– Useless thng here

local text = script.Parent
local val = script.Parent.Parent.Parent.Parent.Handle.On

val.Changed:Connect(function()
	if val.Value == 0 then
        print("Is ready")
		text.Text = "Ready"
		text.TextColor3 = Color3.fromRGB(0, 122, 0)
	elseif val.Value >= 1 then
        print("Is not ready")
		text.Text = val.Value
		text.TextColor3 = Color3.fromRGB(122,0,0)
    else
        print("What")
	end
end)

Try this?

And now it works but WTF
– Y –

I did also go ahead and change your Color3.new to Color3.fromRGB, since Color3.new only takes number values that go up to 1, then afterwards it’s neon pain

Oh that might be why

  • Useless thing -