How to make remoteevent recognize my variable sent by a client sided script?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to try to make a radio

  2. What is the issue? Include screenshots / videos if possible!
    I don’t know how to make a server script recognize a variable sent by a client sided script (Through remoteevent)

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Yes, but none of the posts matched what I am trying to fix.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
Client:

local text = "rbxassetid://"..script.Parent.Parent.TextBox.Text
local MPS = game:GetService("MarketplaceService")

script.Parent.MouseButton1Click:Connect(function(player)
	local radio = game.Players.LocalPlayer.Character.Radio
	radio.MusicEvent:FireServer(text)
	script.Parent.Parent.SongName.Text = MPS:GetProductInfo(text).Name
end)


Server:

script.Parent.MusicEvent.OnServerEvent:Connect(function()
	script.Parent.Music.SoundId = text
	script.Parent.Music:Play()
end)

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

1 Like
script.Parent.MusicEvent.OnServerEvent:Connect(function(player, text)
	script.Parent.Music.SoundId = text
	script.Parent.Music:Play()
end)

This fixed my problem, but the value is blank, help!

Try this:

local MPS = game:GetService("MarketplaceService")
local radio = game.Players.LocalPlayer.Character.Radio

script.Parent.MouseButton1Click:Connect(function(player)
	local text = "rbxassetid://"..script.Parent.Parent.TextBox.Text
	radio.MusicEvent:FireServer(text)
	script.Parent.Parent.SongName.Text = MPS:GetProductInfo(text).Name
end)

nevermind, its fixed lol no need for any more help, so this will be the last reply i guess

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.