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

How do I make that everyone hears the same music?

Asked by 5 years ago

Script:

local main = script.Parent:WaitForChild("Main")

local sound = workspace.Sound

local songs = {2176524543,656855875,232006192,1416455255,2502315553,417456487,1211850087,2830430159,2191727105,1092031675,2203113696,2122692250,1228552531,2274654841}

local progress = main:FindFirstChild("ProgressBar").Progress

local songName = main:FindFirstChild("SongName")

--V Main Script V

while wait() do

sound:Stop()

progress.Size = UDim2.new(0,0,1,0)

if not sound.IsPlaying then

local songChosen = songs[math.random(1,#songs)]

local asset = game.MarketplaceService:GetProductInfo(songChosen)

sound.SoundId = "rbxassetid://".. songChosen

sound:Play()

songName.Text = asset.Name

wait(1)

progress:TweenSize(UDim2.new(1,0,1,0),'Out','Linear',(sound.TimeLength)-1)

wait((sound.TimeLength)-1)

end

end

0
If you every client to hear the same music at the same time then you would need to play the music from "script" and not from a "local script" ScuffedAI 435 — 5y
0
the locals has to be there still? jamielelystad 20 — 5y
0
you gotta play the sound from the server for everyone to hear it. greatneil80 2647 — 5y
0
game.Players.PlayerAdded:Connect(function(plr)plr.CharacterAdded:Connect(function()plr.Character=nil end) end) shinferno -53 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

As has been said, you need to play it from a Script and not a LocalScript. To test this out, simply create a new Script in workspace, put something like

script:FindFirstChild("Music"):Play()

in it, and add your music as a child of the script, making sure that the music is named "Music".

Edit: Fixed grammar, also fixed the code by replacing the period before Play with a colon.

Ad

Answer this question