I'm making a script which will allow players to see the name of a song playing from a song ID. The song would be playing from the server inside speakers all around the build. I'm trying to get this information from the server to each player but I don't have a player argument to send through filteringEnabled because all that this script is meant to do is shuffle through a playlist and send a song ID to speakers, a Player is not being called. How can I make this work?
Server Side
soundsource = game.Workspace.Speakers:FindFirstChild("SpeakerSource").SoundSource speaker = script.Parent playlist = script.Parent.PlaylistTest:GetChildren() shuffle = math.random(1,#playlist) ID = playlist[shuffle].Value SongID = speaker.Value soundsource.Ended:connect(function() wait(2) repeat wait(.001) if speaker.Value == ID then shuffle = math.random(1,#playlist) ID = playlist[shuffle].Value end until speaker.Value ~= ID speaker.Value = ID print("Selected Song") SongID = speaker.Value game.ReplicatedStorage.GSI:FireClient(SongID) end)
Client Side
remote = game:GetService("ReplicatedStorage"):WaitForChild("GSI") SongName = script.Parent.Text remote.OnClientEvent:Connect(function(songID) local asset = game:GetService("MarketplaceService"):GetProductInfo(songID) SongName = "Song Playing: "..asset.Name end)
LocalScript
won't work. You’re just assigning SongName
to the current Text
of script.Parent
, and line 7 does not change the text. You’re just reassigning SongName
. To fix this:local SongName = script.Parent SongName.Text = "TEXT HERE"
FireAllClients
, to fire to all of the clients. Else, you need to get the player.-- Line 24 game:GetService("ReplicatedStorage").GSI:FireAllClients(SongID)