Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Music located in StarterGui() will not play while in game?

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

0

Is your game Filtering Enabled? Objects in StarterGui cannot be accessed in PlayerGui by scripts when Filtering Enabled is on. Try using RemoteEvents.

0

FE is off, and ill look into that

1 answer

Generic loops (for i, v) don't work in the same scope together in one another. While this may not solve it, it is your problem.

Try to make it call a function that has that loop with it and see if anything works.

This discussion is preserved as it was. New answers, comments, and votes are closed.