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

Help with BoolValue?

I have a script that if I click the part, it should make it's child, 'Curve' to true but it's not. I put a test if it works by putting 'print ('change')' and it works but 'Curve' isn't changing to true. Please help.

cur = script.Curve.Value
part = script.Parent
clickDetector = Instance.new("ClickDetector", part)

function onMouseClick(player)
	print('change')
	if not cur == true then
  cur = true
	elseif cur == true then
		cur = false
	end
end
clickDetector.MouseClick:connect(onMouseClick)

1 answer

✓ Accepted answer
cur = script.Curve
part = script.Parent
clickDetector = Instance.new("ClickDetector", part)

function onMouseClick(player)
    print('change')
    if not cur.Value == true then
  cur.Value = true
    elseif cur.Value == true then
        cur.Value = false
    end
end
clickDetector.MouseClick:connect(onMouseClick)

You see, if cur were to = the value, then the value would be false/true, so your code would be doing this, if false = true then false = true elseif true = false then true = false. Understand?

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