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

Sound not playing for other players?

Asked by
danglt 185
6 years ago

Gui play script

1function click()
2    game.Players.LocalPlayer.Character.Sounds.SoundId = "http://www.roblox.com/asset/?id=" .. game.Players.LocalPlayer.PlayerGui.radio.Frame.ID.Text
3 
4    game.Players.LocalPlayer.Character.Sounds:Play()
5end
6script.Parent.MouseButton1Click:Connect(click)

script that activates gui and adds sound (Shortened)

01local player = game.Players.LocalPlayer
02script.Parent.Parent.MouseButton1Click:Connect(function()
03        if player.PlayerGui.radio.Frame.Visible == false then
04            player.PlayerGui.radio.Frame.Visible = true
05        elseif player.PlayerGui.radio.Frame.Visible == true then
06            player.PlayerGui.radio.Frame.Visible = false
07        end
08        if player.Character:FindFirstChild("Sounds") == nil then
09         local ss = Instance.new("Sound")
10        ss.Parent = player.Character
11        ss.Name = "Sounds"
12        ss.Looped = true
13        ss.Volume = 1
14        ss.MaxDistance = 1
15        end
16        end

full script

01local GamePassService = game:GetService('GamePassService')
02local PlayersService = game:GetService('Players')
03local player = game.Players.LocalPlayer
04 
05local ID = 3265754
06 
07local player = game.Players.LocalPlayer
08script.Parent.Parent.MouseButton1Click:Connect(function()
09    if game:GetService("MarketplaceService"):PlayerOwnsAsset(player, ID) then
10        if player.PlayerGui.radio.Frame.Visible == false then
11            player.PlayerGui.radio.Frame.Visible = true
12        elseif player.PlayerGui.radio.Frame.Visible == true then
13            player.PlayerGui.radio.Frame.Visible = false
14        end
15        if player.Character:FindFirstChild("Sounds") == nil then
View all 25 lines...
0
well i'll just assume this is on a local script right? DevSersponge 5 — 6y
0
its not working and no output danglt 185 — 6y

1 answer

Log in to vote
1
Answered by 6 years ago
Edited 6 years ago

Problem is that you're creating a sound in a local script.

to solve this we must create a remote event and a server sided script something like this:

Server Script(put it on starterpack) "create it"

01player = script.Parent.Parent
02Character = player.Character
03path = Character --where do you want the remote event
04ev = Instance.new("RemoteEvent",path)
05ev.Name = "soundevent"
06ev.OnServerEvent:connect(function(player,id)
07 local ss = Instance.new("Sound")
08 ss.Parent = Character
09 ss.SoundId = id
10 ss.Name = "Sounds"
11 ss.Looped = true
12 ss.Volume = 1
13 ss.MaxDistance = 1
14end)

Local Script(i dont know where it is) "This is the script you've posted above"

01local GamePassService = game:GetService('GamePassService')
02local PlayersService = game:GetService('Players')
03local player = game.Players.LocalPlayer
04ev = player.Character.soundevent --Insert Path for the remote event here
05 
06local ID = 3265754
07 
08local player = game.Players.LocalPlayer
09script.Parent.Parent.MouseButton1Click:Connect(function()
10    if game:GetService("MarketplaceService"):PlayerOwnsAsset(player, ID) then
11        if player.PlayerGui.radio.Frame.Visible == false then
12            player.PlayerGui.radio.Frame.Visible = true
13        elseif player.PlayerGui.radio.Frame.Visible == true then
14            player.PlayerGui.radio.Frame.Visible = false
15        end
View all 24 lines...

this should do, in case it doesn't i'll be glad to help again and fix the problem

0
So i have a different GUI that changes the soundid so should i keep everything the same and add a event to that? danglt 185 — 6y
Ad

Answer this question