Need to trigget prompt 2 times before it works; works fine after?

Proximity prompt needs to be triggered 2 times before it works, why is that?

--Services--
local ReplicatedStorage = game:GetService("ReplicatedStorage")

--Alarm Bool Values
local AlarmBoolFolder = ReplicatedStorage.AlarmBoolValues
local FireBool = AlarmBoolFolder.AlarmFire
local EvacBool = AlarmBoolFolder.AlarmEvacuation
local LockBool = AlarmBoolFolder.AlarmLockdown

--Variables--
local ShutdownModel = workspace:FindFirstChild("AlarmShutdown")
local LockButton = workspace.Lockdown.Button:FindFirstChild("LockdownPrompt")
local FireButton = workspace.Fire.Button:FindFirstChild("FirePrompt")
local EvacuationButton = workspace.Evacuation.Button:FindFirstChild("EvacuationPrompt")
local Shutdown = workspace.AlarmShutdown.Button:FindFirstChild("ShutdownPrompt")

--Function--
local function ToggleAlarm(AlarmButton:ProximityPrompt, BoolValue, Light, Sound)
	AlarmButton.Triggered:Connect(function()
		Sound.Parent = workspace.AlarmSounds
		Sound:Play()
		
		BoolValue.Value = true
		Light.Material = Enum.Material.Neon
	end)
end

local function ToggleOff(BlueLight, RedLight, BlackLight)
	BlueLight.Material = Enum.Material.Glass
	RedLight.Material = Enum.Material.Glass
	BlackLight.Material = Enum.Material.Glass
end

--Main Script--
LockButton.Triggered:Connect(function()
	ToggleAlarm(LockButton, LockBool, Shutdown.Parent.Parent:FindFirstChild("Bluelight"), ReplicatedStorage.Sounds.Lockdown)
end)
FireButton.Triggered:Connect(function()
	ToggleAlarm(FireButton, FireBool, Shutdown.Parent.Parent:FindFirstChild("Redlight"), ReplicatedStorage.Sounds.Lockdown)
end)
EvacuationButton.Triggered:Connect(function()
	ToggleAlarm(EvacuationButton, EvacBool, Shutdown.Parent.Parent:FindFirstChild("Yellowlight"), ReplicatedStorage.Sounds.Lockdown)
end)
Shutdown.Triggered:Connect(function()
	for Index, Value in ipairs(AlarmBoolFolder:GetChildren()) do
		Value.Value = false
	end
	ToggleOff(ShutdownModel.Bluelight, ShutdownModel.Redlight, ShutdownModel.Yellowlight)
	for Index, Value in ipairs(workspace.AlarmSounds:GetChildren()) do
		Value:Destroy()
	end
end)

This is the code im using… Can anyone help me out and tell me why this isn’t working the way i want it to… thanks!

This function doesn’t do anything:

local function ToggleAlarm(AlarmButton:ProximityPrompt, BoolValue, Light, Sound)
	AlarmButton.Triggered:Connect(function()
		Sound.Parent = workspace.AlarmSounds
		Sound:Play()

		BoolValue.Value = true
		Light.Material = Enum.Material.Neon
	end)
end

But this function you have inside of it does:

	AlarmButton.Triggered:Connect(function()
		Sound.Parent = workspace.AlarmSounds
		Sound:Play()

		BoolValue.Value = true
		Light.Material = Enum.Material.Neon
	end)

Why do you have a function that holds a Triggered event?

1 Like

Oh my fucking gosh, its late i didnt even notice bruuuh. THANK YOOU!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.