How to make burner on stove turn on using proximity prompt

Hello! I am trying to make the burner on my stove turn on using only a proximity prompt. I am quite new to scripting so it is a bit confusing. The thing I don’t understand is how to make the fire turn on or off. In my situation I cant use my left mouse button to turn the burner on or off, because of different parts of my game so it needs to be a proximity prompt.

function Burn()
	if script.Parent.Triggered == true then
		script.Parent.Parent.Parent.Fire.Fire = true
		script.Parent.Parent.Parent.Fire.Fire = false

roblox burner

Have you read this?

Ok so what you need to do is use a Triggered function, not an if statement.



To check if it’s already activate you can use a variable.

local activated = false
if activated = false then -- Write Code when you want to turn on stove
activated = true
else -- write code to turn off stove
activated = false
local Prompt = script.Parent
local Fire = script:FindFirstAncestor("Fire")

	print(Player.Name.." triggered the prompt.")
	Fire.Fire = not Fire.Fire

If you want the prompt to act as a toggle then this is the simplest way to go about that.