ClickDetector won't change text

I’'m trying to change the Text and TextColor of a TextLabel with a ClickDetector.

It’s probably a dumb question but I don’t use ClickDetectors
There are no errors. in the output.

local CP1 = workspace.CoolingStatusScreen.Part.SurfaceGui.CP1

function onClicked()
    if CP1.Text == "ONLINE" then 
        CP1.Text = "OFFLINE"
        CP1.TextColor3 = Color3.fromRGB(255, 0, 0)

    else

        if CP1.Text == "OFFLINE" then
            CP1.Text = "ONLINE"
            CP1.TextColor3 = Color3.fromRGB(0, 255, 0)
        end
    end
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)
1 Like

Hi, I tested your code and it works fine, Make sure explorer looks like this:
Zrzut ekranu 2020-12-17 193521

1 Like

Make sure the text is set exactly to either OFFLINE or ONLINE respectively in uppercase.
There may be no error if both conditional statements are returning false.

2 Likes

@rudychudyPL
Yes my Explorer looks like this already.
image

Yes, they are both in uppercase.

Are you sure there are no spaces in the text?

My bad, I forgot that I added another TextLabel called “Status” which is what I wanted to change :man_facepalming:
Thanks for all the help though.
image