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

Sound not playing for other players?

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)

2 comments

0

well i'll just assume this is on a local script right?

0

its not working and no output

1 answer

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

1 comment

0

So i have a different GUI that changes the soundid so should i keep everything the same and add a event to that?

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