Proximity Prompt stops working after few uses

What is the issue?
Every Proximity Prompt in my place doesn’t work after a few uses. I have tried searching on the forum but nothing came for my problem.

I have no idea why is this happening.
Here is the script for the light proximity prompt switch.

local lighter = script.Parent.Parent.Parent.Parent.Light.LightPart.SurfaceLight
local ON = true
local sfx = script.Parent.Parent.sfx

script.Parent.Triggered:Connect(function()
	if ON then
		ON = false
		sfx:Play()
		lighter.Enabled = true
	elseif ON == false then
		ON = true
		sfx:Play()
		lighter.Enabled = false
	end
end)

The script for the door proximity prompt.

script.Parent.Triggered:Connect(function(player)
	player.Character:WaitForChild("HumanoidRootPart").Position = Vector3.new(303.379, 6.536, 164.728)
	player.PlayerGui:WaitForChild("dark").Frame.Visible = true
	game.Workspace.open:Play()
	wait(0.8)
	game.Workspace.close:Play()
	player.PlayerGui:WaitForChild("dark").Frame.Visible = false
end)

Yeah the scripts are kind of messy. I am not the best developer. And this is my first topic on the DevForum. I don’t really know what to write else.

Its very likely because you’re spamming it. Add a system which prevents users from spamming:

local lighter = script.Parent.Parent.Parent.Parent.Light.LightPart.SurfaceLight
local ON = true
local sfx = script.Parent.Parent.sfx

script.Parent.Triggered:Connect(function()
	if ON then
		ON = false
		sfx:Play()
		lighter.Enabled = true
script.Parent.Enabled = false
wait(2) -- change this value
script.Parent.Enabled = true

	elseif ON == false then

		ON = true
		sfx:Play()
		lighter.Enabled = false
script.Parent.Enabled = false
wait(2) -- change this value
script.Parent.Enabled = true
	end
end)

and for the door

script.Parent.Triggered:Connect(function(player)
	player.Character:WaitForChild("HumanoidRootPart").Position = Vector3.new(303.379, 6.536, 164.728)
	player.PlayerGui:WaitForChild("dark").Frame.Visible = true
	game.Workspace.open:Play()

script.Parent.Enabled = false

	wait(0.8)
	game.Workspace.close:Play()
	player.PlayerGui:WaitForChild("dark").Frame.Visible = false
script.Parent.Enabled = false
wait(2) -- change this value
script.Parent.Enabled = true
end)
1 Like

I have added a cool down for the light and the door. They still do the same thing.

Have it print something every time you trigger it, and see if it prints

Still the same thing. If the light or the door works it prints my word. But then after a few tries it just doesn’t work.

I don’t really see why this is happening. Are there any other scripts that may modify this or are there any free models with scripts?

1 Like