Hello, Beginner here, I want to make a simple On/Off Button that changes a label. It’s supposed to represent if the pump is enabled.
My master script needs to know so it constantly checks if the Pump is off or on via the label. It may not be that good performance wise but it’s my first game anyway.
TL;DR I need my label to say Off or On but it always says On even tho print() says the Text value is off
So I change the label from Off to On via the script. However, the odd thing is that it dosen’t “update” the text.
That means the Text Value IS OFF even tho it SHOWS THE PLAYER ON. So it DOES kinda work but the player dosen’t know because it dosen’t say so.
local displayStatus = script.Parent.Parent.Parent.Text
local clickDetector = script.Parent
if displayStatus == "Off" then
script.Parent.Parent.BrickColor=BrickColor.new("Really red")
else
script.Parent.Parent.BrickColor=BrickColor.new("Lime green")
end
function onMouseClick()
print(displayStatus)
if displayStatus == "On" then
displayStatus = "Off"
script.Parent.Parent.BrickColor=BrickColor.new("Really red")
elseif displayStatus == "Off" then
displayStatus = "On"
script.Parent.Parent.BrickColor=BrickColor.new("Lime green")
end
print(displayStatus)
end
clickDetector.MouseClick:connect(onMouseClick)
It’s a bit diffilcult to explain, but basically in-game the button says Off even tho it’s value is On (says print).
My hierachy looks something like this:
Edit: Ok, another problem. When my main script checks the text variable it always thinks the button is On (as the label says) even tho my script that does the on/off stuff says otherwise. ahhhh