Gui play script
1 | function 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() |
5 | end |
6 | script.Parent.MouseButton 1 Click:Connect(click) |
script that activates gui and adds sound (Shortened)
01 | local player = game.Players.LocalPlayer |
02 | script.Parent.Parent.MouseButton 1 Click: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
01 | local GamePassService = game:GetService( 'GamePassService' ) |
02 | local PlayersService = game:GetService( 'Players' ) |
03 | local player = game.Players.LocalPlayer |
04 |
05 | local ID = 3265754 |
06 |
07 | local player = game.Players.LocalPlayer |
08 | script.Parent.Parent.MouseButton 1 Click: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 |
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"
01 | player = script.Parent.Parent |
02 | Character = player.Character |
03 | path = Character --where do you want the remote event |
04 | ev = Instance.new( "RemoteEvent" ,path) |
05 | ev.Name = "soundevent" |
06 | ev.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 |
14 | end ) |
Local Script(i dont know where it is) "This is the script you've posted above"
01 | local GamePassService = game:GetService( 'GamePassService' ) |
02 | local PlayersService = game:GetService( 'Players' ) |
03 | local player = game.Players.LocalPlayer |
04 | ev = player.Character.soundevent --Insert Path for the remote event here |
05 |
06 | local ID = 3265754 |
07 |
08 | local player = game.Players.LocalPlayer |
09 | script.Parent.Parent.MouseButton 1 Click: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 |
this should do, in case it doesn't i'll be glad to help again and fix the problem