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

How would I make something that I click revert when I click it again?

I have a part which as a fire effect, so far I have it that when you click it the fire will be enabled. I don't how to make it when I click it again the fire will be disabled.

Current Script -

local fire = script.Parent.Fire

script.Parent.ClickDetector.MouseClick:Connect(function(plr)
		fire.Enabled = true	
	end)

Currently it's very simple but I have no clue how to go about adding to it.

2 answers

try this

local fire = script.Parent.Fire

script.Parent.ClickDetector.MouseClick:Connect(function(plr)
if fire.Enabled == false then
fire.Enabled = true
else
if fire.Enabled = true then
fire.Enabled = false

end
end

end)

You could do like a debounce. So, what it'll do is it'll detect if the condition is true, if it is then Enable the fire, but enabling it will make the condition go 'false', so if you click it again it will not pass the condition, but another if statement that checks whether the condition is false will disable the fire. In this case the fire can be the debounce. A bit confused? Let me give you an example.

local fire = script.Parent.Fire

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

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