How can I fix this script

Trying to make a lamp, where you hold down E the light will turn on, wait 5 seconds, then turn off, and the proximity prompt can no longer be activated
(I turned brightness up to 40 to test)

script.Parent.ProximityPrompt.Triggered:Connect(function()
	script.Parent.Light.SurfaceLight.Brightness = 40
	wait(5)
	script.Parent.Light.SurfaceLight.Brightness = 0
	script.Parent.Plane.ProximityPrompt:Destroy()
	script.Parent.Light.SurfaceLight:Destroy()
end)

So the problem is that you can not reactivate your proximity prompt again? That is because you are deleting it from this line.


script.parent.plane.proximityprompt:Destroy()

no, I want it to not be able to be reactivated, but the issue i’m having is the brightness is not working.
Probably should have been more clear, sorry.

I’m not sure about the surface light, we may need more info but for the prompt at the beginning you are using different prompts

script.Parent.ProximityPrompt
--vs
script.Parent.Plane.ProximityPrompt

That may be causing an issue

1 Like

Okay I’m not exactly sure how your objects are set up but, try using SurfaceLight.Enabled instead of SurfaceLight.Brightness

If you don’t want it to be activated again, you can change the MaxActivationDistance to 0 in the Proximity Prompt with the script.

script.Parent.ProximityPrompt.Triggered:Connect(function()
	script.Parent.Light.SurfaceLight.Brightness = 40
	wait(5)
	script.Parent.Light.SurfaceLight.Brightness = 0
	script.Parent.ProximityPrompt.MaxActivationDistance = 0
end)