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

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

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

✓ Accepted answer

###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)

1 comment

0

Thanks! I never heard of FireAllClients until now, incredibly useful.

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