Issue with Playing Sounds

I am having an issue with playing a sound. Here is my code:

RadioEvent.OnServerEvent:Connect(function(Player,Message,Channel,Type)
	ConfigMessage(Player,Message,Channel)
	
	if Type == "panic" then
		game:GetService("SoundService").PanicButtonSound:Play()
	end
	
	if Type == "radio" then
		game:GetService("SoundService").RadioSound:Play()
	end
end)

It works perfectly fine in local scripts but doesn’t work at all in server scripts. I have tried changing the location of the sound from Workspace to SoundService and even to the script’s parent, but the sound still seems to not play.

(fyi, ‘Type’ outputs ‘panic’)

My sound is up all the way, there are no errors and as I said, it works in local scripts but just not server scripts. Also, I used print earlier to check if the code is actually executing and it is. Any kind of help would be appreciated.

Thanks a lot!

1 Like

Try with this script:

local function Event(Player,Message,Channel,Type)
	ConfigMessage(Player,Message,Channel)

	if Type == "panic" then
		game:GetService("SoundService").PanicButtonSound:Play()
	end

	if Type == "radio" then
		game:GetService("SoundService").RadioSound:Play()
	end
end

RadioEvent.OnServerEvent = Event
1 Like

OnServerEvent is not a valid member of RemoteEvent "ReplicatedStorage.RadioRemoteEvents.RadioEvent"

Could I please see the script which is calling the RemoteEvent?

1 Like

Server Script before your edited code:

local hookURL = ""
local hookURL2 = ""
local httpService = game:GetService("HttpService")

local RadioRemoteEvents = game.ReplicatedStorage.RadioRemoteEvents
local RadioEvent = RadioRemoteEvents.RadioEvent
local PanicEvent = RadioRemoteEvents.PanicEvent

function DisplayMessage(FrameToOutput,Message)
	FrameToOutput.LineFive.Text = FrameToOutput.LineFour.Text 
	FrameToOutput.LineFour.Text = FrameToOutput.LineThree.Text 
	FrameToOutput.LineThree.Text = FrameToOutput.LineTwo.Text 
	FrameToOutput.LineTwo.Text = FrameToOutput.LineOne.Text 
	FrameToOutput.LineOne.Text = Message
end

function ConfigMessage(Player,Message,Channel)
	local RadioGui = script.Parent
	local FrameToOutput = RadioGui.RadioFrame:FindFirstChild(Channel)
	local ConfiguredMessage = Player.Name..": "..Message
	DisplayMessage(FrameToOutput,ConfiguredMessage)
end

RadioEvent.OnServerEvent:Connect(function(Player,Message,Channel,Type)
	ConfigMessage(Player,Message,Channel)
	
	if Type == "panic" then
		game:GetService("SoundService").PanicButtonSound:Play()
	end
	
	if Type == "radio" then
		game:GetService("SoundService").RadioSound:Play()
	end
end)

That means change
if Type == "panic" then
to
if Type == "Panic" then
or
if string.lower(Type) == "panic" then

1 Like

Sorry, I meant that it returns ‘panic’.

The error isn’t coming from it.

1 Like

I’m not getting any error though.

I may be wrong, but this script isn’t invoking the RemoteEvent.

1 Like

The code inside the remote event triggers though. The sound just doesn’t play.

Oh my! Did you just share your discord webhooks? Everyone can use them ya know

1 Like

Oops, thanks for that. I must’ve missed them.

For anyone wondering, I fixed my issue with this code:

local RadioAnimationTrack
local RadioAnimation = script.RadioAnimation
local player = game.Players.LocalPlayer
local char = player.Character
local hum = char:WaitForChild("Humanoid")

RadioAnimationTrack:Play()
1 Like