Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How come no one can hear the sound even though i added RemoteEvent?

- LocalScript
wait(1)
local sound = game:GetService("ReplicatedStorage").Sound
local player = game.Players.LocalPlayer.Character
sound.Parent = player.Radio
local frame = script.Parent:WaitForChild("Frame")
local text = frame.Input.Text
local Format = "http://www.roblox.com/asset/?id=##ID##"

frame:WaitForChild("Play").MouseButton1Click:connect(function()
	local input = tonumber(frame:WaitForChild("Input").Text)
	if input then
	sound.SoundId=Format:gsub("##ID##", tostring(input))
	game.ReplicatedStorage.RemoteEvent:FireServer(sound)
	print("Event Fired")
	end
end)

frame:WaitForChild("Stop").MouseButton1Click:connect(function()
	sound:Stop()
end)
-- Script
game:GetService("ReplicatedStorage").RemoteEvent.OnServerEvent:Connect(function(Player, sound)
	sound:Play()
	print("Event Works")
end)

1 comment

0

I can’t help you. But I’ll tell you what Remote Event is. It doesn’t work.

1 answer

Line 11 is the problem:

local input = tonumber(frame:WaitForChild("Input").Text)

If the length of the original string, Input.Text, is 0, then you'll get a blank return value.

Simple debug:

if #frame:WaitForChild("Input").Text > 0 and tonumber(frame:WaitForChild("Input").Text) then

To check if the ID is valid and can be loaded, you can view this question's answer.

Once that has passed, check to see if the sound has successfully loaded using IsLoaded...

if sound.IsLoaded then

...and if the condition evaluates to true, play the sound:

sound:Play()

5 comments

0

still the same tho :/

0

Are you playing it from the client?

0

Yes

0

Well, that's why. If you play it on the client, only the client can hear it. If you want everybody to hear it, play it from the server.

0

That’s what I did

This discussion is preserved as it was. New answers, comments, and votes are closed.