Boolvalue script

hello,
I’m having a problem with my bool values in a script.
I made my script so it checks or the values are true so the line of code can run.
But here’s my problem the script only runs if the value is true when i go test it and not after I change it

-- wait(4)
local check1 = script.Parent.Parent.Lock.Lock.Unlock.Value
local check2 = script.Parent.Parent.Lock2.Lock.Unlock.Value

local plank = script.Parent

if check1 == true and check2 == true then
	plank.Color = Color3.new(0.388235, 1, 0.294118)
end

I added clickdetectors in a part so the value changes from false to true and when it works the part becomes green

1 Like

You can try @EmbatTheHybrid’s code…

That code only really works if check1 is changed, check2 needs to be checked for as well so that way it has full functionality

Also you’re comparing instances to a boolean, you forgot to do the .Value, I can understand these mistakes, part of improvment

local check1 = script.Parent.Parent.Lock.Lock.Unlock
local check2 = script.Parent.Parent.Lock2.Lock.Unlock

local plank = script.Parent

local function checkLocks()
	if not check1.Value or not check2.Value then
		return
	end
	plank.Color = Color3.new(0.388235, 1, 0.294118)
end

check1.Changed:Connect(checkLocks)
check2.Changed:Connect(checkLocks)
checkLocks()
2 Likes

oh yeah. Thanks for telling me…

tysm this is exactly the answer I was searching for.

1 Like