· 4 years ago · May 13, 2021, 02:56 PM
1--//SETTINGS//--
2local groupId = 0
3local minRankToSkip = 0
4local gamepassId = 0
5local devproductId = 0
6
7--//SCRIPT//--
8local mp = game:GetService('MarketplaceService')
9
10local sound = Instance.new("Sound", workspace)
11sound.Name = "JVRONN_MusicSystem"
12sound.Playing = true
13sound.Volume = 1
14
15local musicEvent = Instance.new("RemoteEvent", game.ReplicatedStorage)
16musicEvent.Name = "MusicEvent1"
17
18local music = {}
19local requests = {}
20
21game.Players.PlayerAdded:Connect(function(p)
22 p.Chatted:Connect(function(m)
23 if(m:lower() == "!skip" or m:lower() == "/e !skip") then
24 if p:GetRankInGroup(groupId) >= minRankToSkip then
25 wait(0.5)
26 local old = sound.SoundId
27 local newSong = music[math.random(1, #music)]
28 while(old == newSong) do
29 newSong = music[math.random(1, #music)]
30 end
31 playMusica(newSong)
32 end
33 end
34 end)
35end)
36
37--// REMOVE THE HYPHENS IF YOU WILL USE TRELLO !!
38
39--local http = game:GetService('HttpService')
40--local mp = game:GetService('MarketplaceService')
41
42--local trello = "" -- trello boardID here
43--local k = "" -- trello api key here
44--local t = "" -- trello token here
45
46--local get = http:GetAsync('https://api.trello.com/1/boards/'..trello..'/lists?key='..k..'&token='..t,true)
47--local tab = http:JSONDecode(get)
48
49function PositiveIntegerMask(String)
50 return String:gsub("%D+", "")
51end
52
53for i,v in pairs(script.Sound:GetChildren()) do
54 table.insert(music, v.SoundId)
55end
56
57local function IsSound(id)
58 local success, value = pcall(function()
59 return mp:GetProductInfo(id).AssetTypeId
60 end)
61 if success then
62 if mp:GetProductInfo(id).AssetTypeId == 3 then
63 return true
64 else
65 return false
66 end
67 else
68 return false
69 end
70end
71
72--for i,v in pairs(tab) do
73-- if v.name == "Music List" then
74-- print("Music list founded!")
75-- local musget = http:GetAsync('https://api.trello.com/1/lists/'..v.id..'/cards?key='..k..'&token='..t,true)
76-- local mustab = http:JSONDecode(musget)
77-- for _,m in pairs(mustab) do
78-- table.insert(music, "rbxassetid://"..m.name)
79-- end
80-- end
81--end
82
83wait(.5)
84
85function playMusica(SoundId)
86 if #requests > 0 then
87 local oldSong = sound.SoundId
88 sound.SoundId = requests[1]
89 sound.Playing = true
90 local ID = PositiveIntegerMask(requests[1])
91 local Asset = mp:GetProductInfo(ID)
92 local Publisher = Asset.Creator.Name
93 local AudioName = Asset.Name
94 wait()
95 requests['rbxassetid://'..ID] = nil
96 table.remove(requests, 1)
97 musicEvent:FireAllClients(Publisher, AudioName)
98 sound:Play()
99 return
100 end
101 local oldSong = sound.SoundId
102 sound.SoundId = SoundId
103 local ID = PositiveIntegerMask(SoundId)
104 local Asset = mp:GetProductInfo(ID)
105 local Publisher = Asset.Creator.Name
106 local AudioName = Asset.Name
107 wait(1)
108 musicEvent:FireAllClients(Publisher, AudioName)
109 sound:Play()
110 sound.Playing = true
111end
112
113wait(3)
114print(#music)
115playMusica(music[math.random(1, #music)])
116
117sound.Ended:Connect(function()
118 wait(0.5)
119 local old = sound.SoundId
120 local newSong = music[math.random(1, #music)]
121 while(old == newSong) do
122 newSong = music[math.random(1, #music)]
123 end
124 playMusica(newSong)
125end)
126
127game.ReplicatedStorage:WaitForChild("addSong").OnServerEvent:Connect(function(p, id)
128 if mp:UserOwnsGamePassAsync(p.UserId,gamepassId) then
129 if IsSound(id) == true then
130 --[[for _,v in pairs(requests) do
131 if PositiveIntegerMask(v) == id then
132 game.ReplicatedStorage.addSong:FireClient(p,"failed")
133 else
134 table.insert(requests, "rbxassetid://"..id)
135 game.ReplicatedStorage.addSong:FireClient(p,"success")
136 end
137 end]]
138 -- local songNam = game:GetService("MarketplaceService"):GetProductInfo(id).Name
139 -- print(p, songNam)
140 if not requests['rbxassetid://'..id] then
141 print("Not found")
142 table.insert(requests,"rbxassetid://"..id)
143 requests['rbxassetid://'..id] = true
144 game.ReplicatedStorage.addSong:FireClient(p,"success")
145 else
146 print("Found")
147 game.ReplicatedStorage.addSong:FireClient(p,"failed")
148 end
149 end
150 else
151 local success, Info = pcall(mp.GetProductInfo, mp, id)
152 local inqueue = nil
153 if success then
154 print("Success! Checking if song is in queue...")
155 if #requests ~= 0 then
156 for _,v in pairs(requests) do
157 if PositiveIntegerMask(v) == id then
158 game.ReplicatedStorage.addSong:FireClient(p,"failed")
159 inqueue = true
160 else
161 inqueue = false
162 end
163 end
164 else
165 inqueue = false
166 end
167 wait()
168 if inqueue == false then
169 print("Success! Song is not in queue! Prompting product purchase...")
170 mp:PromptProductPurchase(p,devproductId)
171 mp.ProcessReceipt = function(receiptInfo)
172 for i,v in pairs(game.Players:GetPlayers())do
173 if p.UserId == receiptInfo.PlayerId then
174 if receiptInfo.ProductId == devproductId then
175 print("Success! Song will be played next!")
176 table.insert(requests, "rbxassetid://"..id)
177 game.ReplicatedStorage.addSong:FireClient(p,"success")
178 end
179 end
180 end
181 end
182 end
183 else
184 print("Error! The sound doesnt exist!")
185 game.ReplicatedStorage.addSong:FireClient(p,"notsound")
186 end
187 end
188end)