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

Script not working on the game but is fine when tested on Studio, can someone help please?

Haii!

I'm currently trying to make an music player script, which I got done but now when I tried to test it online (on a ROBLOX place), it didin't work. But on ROBLOX Studio, it works perfectly fine.

Here's the script:

while wait(1) do
	
game.Players.PlayerAdded:Connect(function(player)
	
end)

local NowPlaying = script.Parent.Parent.TextLabel
local Sound = script.Parent.Parent.SongPlayer

print("The music player has loaded!")

wait(1)

Sound.SoundId = 'rbxassetid://1051512943'
NowPlaying.Text = 'Running in the OOFs'
script.Parent.Parent.SongPlayer:Play()
script.Parent.Parent.SongPlayer.Ended:Wait()
end

:)

3 comments

0

Remove game.Players.PlayerAdded:Connect(function(player) end) from the loop in while wait(1) do.

0

Don't use wait(1) as a condition.

0

What I'm about to say might seem dumb, but it's also a fact. Some things only work in Roblox Studio, but do nothing in a regular game.

1 answer

replace your whole script with

while wait(1)do
	game.Players.PlayerAdded:Connect(function(player)
		local NowPlaying = script.Parent.Parent.TextLabel
		local Sound = script.Parent.Parent.SongPlayer
		print("The music player has loaded!")
		wait(1)
		Sound.SoundId = 'rbxassetid://1051512943'
		NowPlaying.Text = 'Running in the OOFs'
		script.Parent.Parent.SongPlayer:Play()
		script.Parent.Parent.SongPlayer.Ended:Wait()
	end)
end

tell me if it doesn't work and I'l try re-sripting from scratch

3 comments

0

why use while wait(1) do?

0

Using while wait() do is a bad practice.

0

With that script, it doesn' work at all.

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