Im new to lua. Basically I made this proximity prompt script so whenever it is triggered it activates night mode. The problem is that it works only when you trigger it like for the third time .
here is the script:
local prompt = script.Parent.ProximityPrompt
prompt.Triggered:Connect(function(player)
local lighting = script.Parent.Parent.Parent.Lighting
prompt.Triggered:Connect(function()
if prompt.ActionText == "Night Mode" then
lighting.ClockTime = 24
prompt.ActionText = "Day"
script.Parent.Parent.Parent.Lighting.FogColor = Color3.fromRGB(0, 0, 0)
for _, ff in workspace.TerrainPlate:GetChildren() do
ff.Enabled = true
end
else
lighting.ClockTime = 10
prompt.ActionText = "Night Mode"
for _, ff in workspace.TerrainPlate:GetChildren() do
ff.Enabled = false
end
end
end)
end)