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
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
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
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?