I made a script which detects operation of my restaurant project. If true the panel will show red , If false it will show green. When I change the value server side to true , it will show red. But when I change to false , it will still show red. If there is a fix for this?
game.Workspace.Cashiers[CASHIERCODENAME].Configuration.inuse.Changed:connect(function()
– Check if its in use
if game.Workspace.Cashiers[CASHIER CODENAME].Configuration.inuse then
script.Parent.ImageColor3 = Color3.new(255,0,0) – Changes to red
elseif not game.Workspace.Cashiers[CASHER CODENAME].Configuration.inuse then
script.Parent.ImageColor3 = Color3.new(85,255,0) – Changes to green ( not work )
end
end)
You probably meant game.Workspace.Cashiers[CASHIER CODENAME].Configuration.inuse.Value (note the .Value at the end.)
The elseif is redundant, btw. A boolean can only be true or false, anyway. Just use an else instead.
Oh, and for ValueObjects, the .Changed function passes the new value of the ValueObject to the function.
Here’s a fixed, better version of what you have right now.
local inuse = game.Workspace.Cashiers[CASHIERCODENAME].Configuration.inuse
inuse.Changed:connect(function(isInUse)
-- Check if its in use
if isInUse then
script.Parent.ImageColor3 = Color3.new(255,0,0) -- Changes to red
else
script.Parent.ImageColor3 = Color3.new(85,255,0) -- Changes to green ( not work )
end
end)
Right. Color3.new takes inputs in the range 0-1 (e.g. [1, 0, 0] is pure red) . You probably meant to use Color3.fromRGB, which takes in 0-255 (so that [255, 0, 0] is pure red).