Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 7 years ago
Edited 7 years ago

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

Log in to vote
1
Answered by 7 years ago
Edited 7 years ago

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.

0
I think this should work as long as I put the audio on looped.true Thanks! Unkn0wn_Species 20 — 7y
0
How would I add a second audio to this? Unkn0wn_Species 20 — 7y
Ad

Answer this question