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

How do you make if and else statements using bool values?

I've tried putting this script inside a fire object using the boolvalue "flareson"

if game.workspace.flareson.value = true 
then script.Parent.Enabled = true
else script.Parent.Enable = false

but the fire object is on, even though flareson's value property is unchecked.

2 comments

0

I think there's a 'd' missing from Enabled on the last line. Was that in the script of just a typo in the question?

0

Likely a typo.

2 answers

✓ Accepted answer

To constantly sense the status of an object, do this:

game.Workspace:WaitForChild("flareson").Changed:Connect(function(IsOn)--IsOn will return as the value of the flare
	script.Parent.Enabled = IsOn
end)

Short and sweet. With further questions/comments/concerns, feel free to reply. Happy scripting! ~mc3334

your syntax is wrong it should be

function flareson()
	if game.Workspace.flareson.Value == true then
		script.Parent.Enabled = true
	else
		script.Parent.Enabled = false
	end
end

you need two equal signs when comparing values in an if statement, only one is needed when setting/changing values

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