Prox prompt, script does activate part again after the disabling one

Problem is that after disabling part, script does activate part again. Have tried lot of thing that already forgot they were.


ProximityPrompt.Triggered:connect(function(Player)
	if ProximityPrompt.ActionText == "Activate" then
		for i,Player in ipairs(game.Players:GetPlayers()) do
			workspace.OverwatchSounds.JW_CITADEL.music:Play()
			wait(34)
			workspace.OverwatchSounds.INTO_OVERWATCH.music:Play()
			wait(3.6)
		
			workspace.JWOnTouch.Part.Script.Disabled = false
			workspace.OverwatchSounds.JudgementWaiver.music:Play()
			workspace.OverwatchSounds.JW.musicJW:Play()
			workspace.monitor1.Part.Beam1.Enabled = false
			workspace.monitor1.Part.Beam2.Enabled = true
			workspace.monitor2.Part.Beam1.Enabled = false
			workspace.monitor2.Part.Beam2.Enabled = true
			workspace.monitor3.Part.Beam1.Enabled = false
			workspace.monitor3.Part.Beam2.Enabled = true
			workspace.monitor4.Part.Beam1.Enabled = false
			workspace.monitor4.Part.Beam2.Enabled = true
			workspace.monitor5.Part.Beam1.Enabled = false
			workspace.monitor5.Part.Beam2.Enabled = true
			workspace.Citadel.Model.LightBeam1.Light1.Enabled = false
			workspace.Citadel.Model.LightBeam1.Light2.Enabled = true
			workspace.Citadel.Model["Part2-1"].Transparency = 1
			workspace.Citadel.Model["Part2-2"].Transparency = 0
			workspace.OverwatchSounds.JW.fakelight:Play()
			wait(0.900)

			workspace.Citadel.Model.LightBeam2.Light1.Enabled = false
			workspace.Citadel.Model.LightBeam2.Light2.Enabled = true
			workspace.Citadel.Model["Part1-1"].Transparency = 1
			workspace.Citadel.Model["Part1-2"].Transparency = 0
			workspace.OverwatchSounds.JW.fakelight:Play()
			wait(0.900)

			workspace.Citadel.Model.Flash1.Light.Light.ImageTransparency = 0
			workspace.OverwatchSounds.JW.fakelight:Play()
			wait(0.900)

			workspace.Citadel.Model.Flash2.Light.Light.ImageTransparency = 0
			workspace.OverwatchSounds.JW.fakelight:Play()
			wait(0.900)

			workspace.Citadel.Model.Flash3.Light.Light.ImageTransparency = 0
			workspace.OverwatchSounds.JW.fakelight:Play()
			wait(0.900)
			wait(8.100)
			
			workspace.OverwatchSounds.JW.fakeJW:Play()
			wait(6.630)
			workspace.OverwatchSounds.JW.realJW:Play()
			script.Parent.ActionText = "Disable"
		end
	elseif ProximityPrompt.ActionText == "Disable" then
		for i,Player in ipairs(game.Players:GetPlayers()) do
			workspace.JWOnTouch.Part.Script.Disabled = true
			workspace.OverwatchSounds.JW.realJW:Stop()
			workspace.OverwatchSounds.JW.musicJW:Stop()
			workspace.monitor1.Part.Beam1.Enabled = true
			workspace.monitor1.Part.Beam2.Enabled = false
			workspace.monitor2.Part.Beam1.Enabled = true
			workspace.monitor2.Part.Beam2.Enabled = false
			workspace.monitor3.Part.Beam1.Enabled = true
			workspace.monitor3.Part.Beam2.Enabled = false
			workspace.monitor4.Part.Beam1.Enabled = true
			workspace.monitor4.Part.Beam2.Enabled = false
			workspace.monitor5.Part.Beam1.Enabled = true
			workspace.monitor5.Part.Beam2.Enabled = false
			workspace.OverwatchSounds.JW_CITADEL.music:Play()
			workspace.Citadel.Model.LightBeam1.Light1.Enabled = true
			workspace.Citadel.Model.LightBeam1.Light2.Enabled = false
			workspace.Citadel.Model["Part2-1"].Transparency = 0
			workspace.Citadel.Model["Part2-2"].Transparency = 1
			workspace.OverwatchSounds.JW.fakelight:Play()
			wait(0.900)

			workspace.Citadel.Model.LightBeam2.Light1.Enabled = true
			workspace.Citadel.Model.LightBeam2.Light2.Enabled = false
			workspace.Citadel.Model["Part1-1"].Transparency = 0
			workspace.Citadel.Model["Part1-2"].Transparency = 1
			workspace.OverwatchSounds.JW.fakelight:Play()
			wait(0.900)

			workspace.Citadel.Model.Flash1.Light.Light.ImageTransparency = 1
			workspace.OverwatchSounds.JW.fakelight:Play()
			wait(0.900)

			workspace.Citadel.Model.Flash2.Light.Light.ImageTransparency = 1
			workspace.OverwatchSounds.JW.fakelight:Play()
			wait(0.900)

			workspace.Citadel.Model.Flash3.Light.Light.ImageTransparency = 1
			workspace.OverwatchSounds.JW.fakelight:Play()
			wait(0.900)
			wait(32.400)
			script.Parent.ActionText = "Activate"
		end
	end	
end)

Do you have anything else that could be firing the ProximetyPrompt?

Try putting a print right after the ProximetyPrompt.Triggered line to see how many times it’s being activated.

If you are using OnTouch for anything that relates to the ProximetyPrompt (JWOnTouch?) and doesn’t have a debounce is that causing multiple firings of the function?

A tip to make things more cleaner and simpler, Is to use for I.

amount = 5
for i = 1,amount do
task.wait(1)
workspace.monitor1.Part.Beam1.Enabled = true
workspace.monitor1.Part.Beam2.Enabled = false
end
1 Like