Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why Sound could not be heard by other player? [RADIO SCRIPT ISSUE]

Asked by 5 years ago
wait(0.5)
local sound = game.ReplicatedStorage.Boombox.Radio.Sound
sound.Volume = 1
local Pitch = script.Parent.Frame:findFirstChild("Pitch")
local VOL = script.Parent.Frame:WaitForChild("LOP")
local player = game.Players.LocalPlayer
repeat wait() until player.Character
sound.Parent = player.Character.Boombox
local Format = "http://www.roblox.com/asset/?id=##ID##"
local frame = script.Parent:WaitForChild("Frame")

frame:WaitForChild("Play").MouseButton1Click:connect(function()
    sound.Pitch = Pitch.Text
    local input = tonumber(frame:WaitForChild("Input").Text)
    if input then
        sound:Stop()
        sound.SoundId = Format:gsub("##ID##", tostring(input))
        sound:Play()
    end
end)
frame:WaitForChild("Stop").MouseButton1Click:connect(function()
    sound:Stop()
end)

frame:WaitForChild("LOP").MouseButton1Click:connect(function()
    if sound.Looped == false then
        sound.Looped = true
        script.Parent.Frame.LOP.Text = " X "
    else
        sound.Looped = false
        script.Parent.Frame.LOP.Text = ""
    end
end)
-- why Sound could not be heard by other players but only you can hear it?

2 answers

Log in to vote
0
Answered by 5 years ago

It's because you're running it on a localscript which plays the sound only to the client.

Ad
Log in to vote
0
Answered by 5 years ago

I think you are doing this in a local script because I see that you used Local Player in your code. If you are doing this in a localscript, then your code will only run on the client, which means the client will see your code's output (the sound). It also means that no other people will hear it, because whatever code is on a local script will not replicate to the server. I am about to tell how to fix this. Here is what you need to do: Use remote events and remote functions. I, unfortunately, do not know much about these objects, but I know a youtube channel that has a few videos about remote events and remote functions. There are also people on this website who know a lot about them. Click here to see tutorials about how to use remotes:

https://www.youtube.com/watch?v=-KqiPiE5P74

https://www.bing.com/videos/search?q=alvinblox+youtube+scripting&&view=detail&mid=E63F800793C453213E39E63F800793C453213E39&&FORM=VRDGAR

If answer does not help you, I am very sorry. If it does, you are welcome.

0
do i need to change anything in this script? MythicTuberHD 0 — 5y

Answer this question