So i made a tourch model, added a ProximityPrompt to one of it’s part and i wanna make it so if you trigger the prompt then a tourch’s fire turns on or off depending if it’s turned on or turned off at the moment.
So when I trigger the prompt i can turn the fire off but can’t turn it back on.
This is the structure of the tourch model:
Holder.ProximityPrompt.Light script:
local prompt = script.Parent
local model = script.Parent.Parent.Parent
local coal = model.Coal
local fire = coal.Fire
local smoke = coal.Smoke
local status = fire.Status.Value
prompt.Triggered:Connect(function()
if status == "true" then
fire.Enabled = false
smoke.Enabled = true
smoke.Enabled = false
prompt.ObjectText = "Light"
prompt.TriggerEnded:Wait()
else
fire.Enabled = true
prompt.ObjectText = "Turn off"
prompt.TriggerEnded:Wait()
end
end)
I get no errors in the output, but the tourch’s fire doesn’t turn back on.
I guess this is causing it. status is storing the value and not the instance. so when the value of instance changes, it won’t change the variable stored in status. Instead try this script
local prompt = script.Parent
local model = script.Parent.Parent.Parent
local coal = model.Coal
local fire = coal.Fire
local smoke = coal.Smoke
local status = fire.Status
prompt.Triggered:Connect(function()
if status.Value then
fire.Enabled = false
smoke.Enabled = true
smoke.Enabled = false
prompt.ObjectText = "Light"
prompt.TriggerEnded:Wait()
else
fire.Enabled = true
prompt.ObjectText = "Turn off"
prompt.TriggerEnded:Wait()
end
end)