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
else
script.Parent.Parent.Parent.Fire.Fire = false
end
end
To check if it’s already activate you can use a variable.
local activated = false
script.Parent.Triggered:Connect(function(plr)
if activated = false then -- Write Code when you want to turn on stove
activated = true
else -- write code to turn off stove
activated = false
end
end)
local Prompt = script.Parent
local Fire = script:FindFirstAncestor("Fire")
Prompt.Triggered:Connect(function(Player)
print(Player.Name.." triggered the prompt.")
Fire.Fire = not Fire.Fire
end)
If you want the prompt to act as a toggle then this is the simplest way to go about that.