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

How would I make a GUI Play Music Server Wide?

For a game a friend and I are making, I wanted to add a sort of intercom room for people who purchase a game pass. In the intercom room you would be able to press a button and after pressing the button it would bring up a client-side GUI where you can paste the song ID of the song you want to play across the whole server. Currently I found out how to do this using local scripts but as I have stated, I would like to have the music play server wide rather than on just the client side. The video I had watched said that in order to make the music play on the server-side rather than the client-side, just convert the scripts from local scripts to normal scripts but when doing this, it made the music no longer play at all. Here is the code responsible for making it play (there is a separate thing of code for stopping the music, if you want to see it just let me know):

local button = script.Parent
local box = button.Parent.MusicBox
local music = button.Parent.Intercom

button.MouseButton1Click:Connect(function()
	music.SoundId = "rbxassetid://"..box.Text
	music:Play()
	music.Playing = true
end)

Sorry if I did not explain too well.

1 comment

0

Use RemoteEvents https://developer.roblox.com/en-us/articles/Remote-Functions-and-Events. Questions? Ping me on the scripting helpers discord

1 answer

Explained on discord.

Script:

local ms = game:GetService("MarketplaceService")
local rs = game:GetService("ReplicatedStorage")
local event = rs:WaitForChild("IntercomMusic")
local sound = rs:WaitForChild("Intercom")
local exceptionList = {"TTChaos", "thesavagery212", 617445798, 1271717842} -- Accepts usernames or userIds

event.OnServerEvent:Connect(function(musicid)
    if ms:GetProductInfo(musicid).AssetTypeId == 3 and (ms:UserOwnsGamePassAsync(player.UserId, 12342609) or table.find(exceptionList, player.Name) or table.find(exceptionList, player.UserId)) then
        sound.SoundId = "rbxassetid://"..musicid
        sound:Play()
    end
end)

LocalScript:

local button = script.Parent
local box = button.Parent.MusicBox
local music = button.Parent.Intercom
local rs = game:GetService("ReplicatedStorage")
local event = rs:WaitForChild("IntercomMusic")

button.Activated:Connect(function()
    event:FireServer(box.Text)
end)

Make a RemoteEvent called IntercomMusic and put it in ReplicatedStorage

Make a Sound called Intercom and put it in ReplicatedStorage

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