Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

why is my boolvalue not changing?

Please tell me what I'm doing wrong here. The boolvalue won't change to true no matter what I do (it is set to false by default)

local IsOn = script.Parent.IsOn.Value

script.Parent.ClickDetector.MouseClick:Connect(function()
	if IsOn==false then
		IsOn=true
	elseif IsOn==true then
		IsOn=false
	end
end)

1 answer

✓ Accepted answer

The issue here is that you need to make the variable refer to the BoolValue and not it's value. Doing local IsOn = script.Parent.IsOn.Value will make IsOn either true or false depending on what it is when you defined it. Try just doing script.Parent.IsOn.

local IsOn = script.Parent.IsOn

script.Parent.ClickDetector.MouseClick:Connect(function()
    if IsOn.Value==false then
        IsOn.Value=true
    elseif IsOn.Value==true then
        IsOn.Value=false
    end
end)

2 comments

0

Thanks again R_alatch, your knowledge in scripting far overpowers mine.

0

You are doing the right things, it's just that simple things like this can make your entire script not function correctly.

This discussion is preserved as it was. New answers, comments, and votes are closed.