I am making a script that once a button is pressed, a series of lanterns are released into the air followed by music and a color effect.
My code works PERFECTLY in studio but not in-game around other players. I put all the sounds into StarterGui, and tried to play them through playerGui.
Here is my code:
script.Parent.ClickDetector.MouseClick:connect(function()
local la = game.Workspace.Lanterns
local lag = la:GetChildren()
for _,v in pairs(game.Players:GetChildren()) do
v.PlayerGui.LIGHT:Play() --Play the new music (located in StarterGui)
v.PlayerGui.Rain:Stop() --STOP current music (also located in StarterGui)
for _,v in pairs(lag) do
spawn(function()
if v.Name == "LanternAtt" then
wait(5)
v.LanternGroup.flame.RodConstraint:Destroy()
for i = (game.Lighting.ColorCorrection.Saturation),0.6,.025 do
game.Lighting.ColorCorrection.Saturation = i
wait(1)
end
end
end)
end
wait(100)
for _,v in pairs (lag) do
v:Destroy()
end
end
end)

2 comments
Is your game Filtering Enabled? Objects in StarterGui cannot be accessed in PlayerGui by scripts when Filtering Enabled is on. Try using RemoteEvents.
FE is off, and ill look into that