Music Player GUI that plays a sound server wide?

Hi!
I wanna make a GUI that creates and plays a sound. The id of the sound is based on the text in TextBox.
For example, if you paste the id of a music and you press on a TextButton, it creates a sound in Workspace and plays it on the whole server.
This is how it looks like:

First I made a LocalScript in a TextButton:

script.Parent.Activated:Connect(function()
	script.Parent.Visible = false
	script.Parent.Parent.BackButton.Visible = false
	script.Parent.Parent.StopButton.Visible = true
	local input = script.Parent.Parent.IDTextBox.Text
	local mps = game:GetService("MarketplaceService")
	local succes, info = pcall(mps.GetProductInfo, mps, input)
	if succes and info.AssetTypeId == 3 then
		script.Parent.Parent.MusicName.Text = "Music name: " .. info.Name.."| By: " .. info.Creator.Name
	end
	local event = script.Parent.Parent.Parent.Remotes.MusicPlayerEvent
	event:FireServer(input)
end)

And here’s the Script, that creates the sound:

local ms = game:GetService("MarketplaceService")
local remotesfolder = script.Parent.Parent:WaitForChild("Remotes")
local event = remotesfolder:WaitForChild("MusicPlayerEvent")

event.OnServerEvent:Connect(function(input)
	local info = pcall(ms.GetProductInfo, ms, input)
	input.AssetTypeId = 3
		local music1 = Instance.new('Sound')
		script.Parent.Parent.MusicPlayerFrame.OrthrosMusic2.SoundId = "rbxassetid://"..input
		music1.Name = "Music1"
		music1.Parent = game.Workspace
		music1.SoundId = script.Parent.Parent.MusicPlayerFrame.Music2.SoundId
		music1:Play()
end)

I always get this error, when I test the GUI.

I tried to formulate my question as well as possible, I hope you understood. If you have any other questions, feel free to ask.
Thanks in advance for your replies.

1 Like

the first argument of onserverevent is the client that fired it, fix it by doing:

event.OnServerEvent:Connect(function(player, input)

Alright, I removed the input.AssetTypeId = 3 line, fixed the OnServerEvent line and it works!!! Tysm!!