Here is a script that checks and changes a string, and for some reason the function runs both statements. Of course both statements are true as it runs through them, however only 1 statement should be able to be run per event trigger, right?
And something even weirder is that it can start by going through the elseif statement, and then in the same event it switches to the if statement. I’m very confused. Here are the prints of the event being triggered twice. It is supposed to only print 2 values, however it prints 4.
game.Lighting.Changed:Connect(function()
if latestZone:match("Day") then
local sound = sounds:FindFirstChild(string.gsub(latestZone, "Day", "Night"))
print(sound)
if sound then
local check = sounds:GetChildren()
for i,v in pairs(check) do
v:Stop()
end
sound:Play()
latestZone = sound.Name
end
elseif latestZone:match("Night") then
local sound = sounds:FindFirstChild(string.gsub(latestZone, "Night", "Day"))
print(sound)
if sound then
local check = sounds:GetChildren()
for i,v in pairs(check) do
v:Stop()
end
sound:Play()
latestZone = sound.Name
end
end
end)