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

function click()
    game.Players.LocalPlayer.Character.Sounds.SoundId = "http://www.roblox.com/asset/?id=" .. game.Players.LocalPlayer.PlayerGui.radio.Frame.ID.Text

    game.Players.LocalPlayer.Character.Sounds:Play()
end
script.Parent.MouseButton1Click:Connect(click)

script that activates gui and adds sound (Shortened)

local player = game.Players.LocalPlayer
script.Parent.Parent.MouseButton1Click:Connect(function()
        if player.PlayerGui.radio.Frame.Visible == false then
            player.PlayerGui.radio.Frame.Visible = true
        elseif player.PlayerGui.radio.Frame.Visible == true then
            player.PlayerGui.radio.Frame.Visible = false
        end
        if player.Character:FindFirstChild("Sounds") == nil then
         local ss = Instance.new("Sound")
        ss.Parent = player.Character
        ss.Name = "Sounds"
        ss.Looped = true
        ss.Volume = 1
        ss.MaxDistance = 1
        end
        end

full script

local GamePassService = game:GetService('GamePassService')
local PlayersService = game:GetService('Players')
local player = game.Players.LocalPlayer

local ID = 3265754

local player = game.Players.LocalPlayer
script.Parent.Parent.MouseButton1Click:Connect(function()
    if game:GetService("MarketplaceService"):PlayerOwnsAsset(player, ID) then
        if player.PlayerGui.radio.Frame.Visible == false then
            player.PlayerGui.radio.Frame.Visible = true
        elseif player.PlayerGui.radio.Frame.Visible == true then
            player.PlayerGui.radio.Frame.Visible = false
        end
        if player.Character:FindFirstChild("Sounds") == nil then
         local ss = Instance.new("Sound")
        ss.Parent = player.Character
        ss.Name = "Sounds"
        ss.Looped = true
        ss.Volume = 1
        ss.MaxDistance = 1
        end
    else game:GetService("MarketplaceService"):PromptPurchase(player, ID)
        end
end)
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"

player = script.Parent.Parent
Character = player.Character
path = Character --where do you want the remote event
ev = Instance.new("RemoteEvent",path)
ev.Name = "soundevent"
ev.OnServerEvent:connect(function(player,id)
 local ss = Instance.new("Sound")
 ss.Parent = Character
 ss.SoundId = id
 ss.Name = "Sounds"
 ss.Looped = true
 ss.Volume = 1
 ss.MaxDistance = 1
end)

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

local GamePassService = game:GetService('GamePassService')
local PlayersService = game:GetService('Players')
local player = game.Players.LocalPlayer
ev = player.Character.soundevent --Insert Path for the remote event here

local ID = 3265754

local player = game.Players.LocalPlayer
script.Parent.Parent.MouseButton1Click:Connect(function()
    if game:GetService("MarketplaceService"):PlayerOwnsAsset(player, ID) then
        if player.PlayerGui.radio.Frame.Visible == false then
            player.PlayerGui.radio.Frame.Visible = true
        elseif player.PlayerGui.radio.Frame.Visible == true then
            player.PlayerGui.radio.Frame.Visible = false
        end
        if player.Character:FindFirstChild("Sounds") == nil then
        local songid = "rbxassetid://279207008" 
-- you can define songid as any song id you want or do anything else that you need
        ev:FireServer(songid) 

        end
    else game:GetService("MarketplaceService"):PromptPurchase(player, ID)
        end
end)

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