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

I'm trying to add music to my game so it starts for all players individually, help?

I'm trying to add music to my game so it starts for all players individually instead of one audio running running already when a player joins, (Ex: Server started 2 minutes ago, another player joins halfway through the audio playing.)

I've tried adding this at the end

if player.PlayerAdded then
sound1:Play()

but it doesn't seem to work help?

Script

local Players = game:GetService("Players")

function onPlayerAdded(player)
	print(player.Name .. " has entered the game")
end

Players.PlayerAdded:Connect(onPlayerAdded)

for _,player in pairs(Players:GetPlayers()) do
	onPlayerAdded(player)
end

1 answer

✓ Accepted answer

If you're saying that you want the music to play only for the player when they join the game, then you can do something like this in a LocalScript.

local player = game.Players.LocalPlayer
local sound = Instance.new("Sound",player)

sound.SoundId = "rbxassetid://"..484369080 --the ID of your sound.
sound:Play()

If I'm interpreting your question wrong, please comment so I can try to help.

2 comments

0

I think this should work as long as I put the audio on looped.true Thanks!

0

How would I add a second audio to this?

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