FM radio in ROBLOX?

I’m trying to make an FM radio system in roblox. Yes, I know that you’ll say “hey the audio thing” but I uploaded custom, copyright-free music for the radio. Anyway I’m trying to make it, but I’m stuck on an issue. The script doesn’t work. I’m using RemoteEvents. Any idea?

Inside the radio handler local script:

local VOLUME_UP = script.Parent.V.V_UP
local VOLUME_DOWN = script.Parent.V.V_DOWN
local CHANNEL_UP = script.Parent.P.P_UP
local CHANNEL_DOWN = script.Parent.P.P_DOWN
local DISPLAY = script.Parent.DISPLAY
local CHANNEL = 0

VOLUME_UP.MouseButton1Down:Connect(function()
	script.Parent.Click:Play()
end)

VOLUME_DOWN.MouseButton1Down:Connect(function()
	script.Parent.Click:Play()
end)

CHANNEL_UP.MouseButton1Down:Connect(function()
	script.Parent.Click:Play()
	CHANNEL += 1
end)

CHANNEL_DOWN.MouseButton1Down:Connect(function()
	script.Parent.Click:Play()
	CHANNEL -= 1
end)

while wait() do
	if CHANNEL == 1 then
		game.ReplicatedStorage.RadioStations.Station:FireServer(CHANNEL, game.Players.LocalPlayer)
	end
end

In the radio station server script:

function OnServerEvent(station, p)
	if station == 1 then
		print("station 0")
		local sound = Instance.new("Sound", p.Character.Torso)
		sound.SoundId = 9340259267
		sound:Play()
	end
end
1 Like

The first argument of a remote event is always the player. Station is a player object, not an integer.

Simply change it to function OnServerEvent(Player, Station). No need to pass the player in the arguments locally.

2 Likes

Hmmm, it still doesn’t work, I removed the player mention from the LocalScript but it doesn’t change anything

Change sound.SoundId = 9340259267 to sound.SoundId = "rbxassetid://9340259267"

1 Like

Still nothing. I checked the explorer, apparently the sound doesn’t even get copied to the player
OH WAIT I THINK I GOT IT

Nah… still nothing, I forgot it was in R15 so I changed it to LowerTorso but it still doesn’t copy

Upon further troubleshooting, I noticed that the server event doesn’t get fired.

Did you connect the OnServerEvent function?

Ah, I forgot to. Let me try. I’ll return and tell if it works or not.

Yes, I did fire the event, check the local script (didnt really understand that’s why I took so long)
Wait no, I still don’t understand?

Yes I connected the function. Still no luck though…

As @wf_sh said the first argument received on the server is always the player so you can remove the player instance in the :FireServer() function

This should then be

function OnServerEvent(p, station)
	if station == 1 then
		print("station 0")
		local sound = Instance.new("Sound")
		sound.SoundId = 9340259267
        sound.Parent = p.Character.HumanoidRootPart --Torso does not exist in R15 characters and also do not set the parent in Instance.new() because it's slower then setting it separately
		sound:Play()
	end
end

Finally on the server connect the event

game.ReplicatedStorage.RadioStations.Station.OnServerEvent:Connect(OnServerEvent)
1 Like

Still nothing. I don’t see any output, I used prints for debugging and it doesn’t output anything.

At least try to describe what happens because saying just “still nothing” is not helpful

Basically:

  • I click the channel up button
  • It makes a beeping noise
  • The sound is supposed to play, and it’s supposed to output “station 0” in the output, but it doesn’t
  • I check the output but nothing relating to “station 0” shows up

There are two possible things happening. The script is either not listening to the event correctly or the station is not 1 and so it’s not continuing after the if statement in the server

Found the issue, it’s the second issue (the station is not 1)

Good if everything is working mark the post of the person who solved the issue as solution

Not yet, still not working, tried NumberValues for the station number, but it doesn’t increase. Do you want the model file so you can examine it yourself?

Send your entire scripts because as of now it is a bit confusing