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

How can I send a value through filteringEnabled when a player isn't called?

Asked by 5 years ago

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)

1 answer

Log in to vote
0
Answered by 5 years ago

Lines 2 and like 7 of your 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"

That will work.

To answer your question, if you don’t want to get the player and still fire the remote, you can use FireAllClients, to fire to all of the clients. Else, you need to get the player.

-- Line 24

game:GetService("ReplicatedStorage").GSI:FireAllClients(SongID)
0
Thanks! I never heard of FireAllClients until now, incredibly useful. BronzedMocha 60 — 5y
Ad

Answer this question