[RESOLVED] Help with proximity prompt light

I need this to repeat as many times as the player wants, similar to the toolbox door example next to it.

For some reason its only working for one go around, anyone have a solution?

Script is bellow.


local proximityprompt = script.Parent.Detect.Attachment.ProximityPrompt
local light = script.Parent.Detect.Attachment.PointLight
local bulb = script.Parent.Cage

--[ Script Bellow ]--

proximityprompt.Triggered:Connect(function()
	if proximityprompt.ActionText == "On" then
		proximityprompt.ActionText = "Off"
		light.Enabled = false
		bulb.Material = "Glass"
	else
		proximityprompt.ActionText = "Off"
		light.Enabled = true
		bulb.Material = "Neon"
	end
end)

You forgor to rename the ActionText in your if Function from “off” to “on”.
Check the last lines.

2 Likes

Wow, that was an easy fix. Thank you!

local proximityprompt = script.Parent.Detect.Attachment.ProximityPrompt
local light = script.Parent.Detect.Attachment.PointLight
local bulb = script.Parent.Cage

local toggle = false
--[ Script Bellow ]--

proximityprompt.Triggered:Connect(function()
	toggle = not toggle
	proximityprompt.ActionText = if toggle then "Off" else "On"
	light.Enabled = if toggle then true else false
	bulb.Material = if toggle then "Neon" else "Glass"
end)

Resolved but here’s an alternate approach.