I’m getting this error with my script…(Screenshot of console found below)
Here’s the script that’s getting the error:
local productId = 1174490066 --your dev product for a song
local trelloboard = "(trelloboard here)" --the thing in the middle of the URL on trello, random letters and numbers
local trellokey = "(trellokey here)" --not required unless private board
local trellotoken = "(trello token here)" --ditto
local Group = 9390991
local RequiredRank = 254 --Rank that can skip songs
local skipratio = 0.35
local songs = {}
local nowplaying = nil
local requests = {
}
local http = game:GetService('HttpService')
local lists = http:JSONDecode(http:GetAsync("https://api.trello.com/1/boards/"..trelloboard.."/lists?key="..trellokey.."&token="..trellotoken))
for _,v in pairs(lists) do
if v.name == "Music List" then
local items = http:JSONDecode(http:GetAsync("https://api.trello.com/1/lists/"..v.id.."/cards?key="..trellokey.."&token="..trellotoken))
for _,v in pairs(items) do
if v.name:match(":") ~= nil then
local s,f = string.find(v.name,":")
warn(string.sub(v.name,f+1))
table.insert(songs, string.sub(v.name,f+1))
end
end
end
end
function shuffleTable(t)
math.randomseed(tick())
assert(t, "shuffleTable() expected a table, got nil" )
local iterations = #t
local j
for i = iterations, 2, -1 do
j = math.random(i)
t[i], t[j] = t[j], t[i]
end
end
shuffleTable(songs)
local songnum = 0
function game.ReplicatedStorage.musicEvents.getSong.OnServerInvoke()
if nowplaying then
return game:service('MarketplaceService'):GetProductInfo(tonumber(nowplaying)).Name
else
return nil
end
end
game.ReplicatedStorage.musicEvents.purchaseSong.OnServerEvent:connect(function(p)
if p.userId > 0 then
game:GetService("MarketplaceService"):PromptProductPurchase(p, productId)
end
end)
local votes = {
}
function makesong()
workspace:WaitForChild("speaker"):WaitForChild("Sound"):Stop()
wait()
if #requests == 0 then
songnum = songnum+1
if songnum > #songs then
songnum = 1
end
nowplaying = songs[songnum]
else
nowplaying = requests[1]
table.remove(requests,1)
end
local thisfunctionssong = nowplaying
workspace.speaker.Sound.SoundId = "rbxassetid://"..thisfunctionssong
wait()
workspace.speaker.Sound:Play()
game.ReplicatedStorage.musicEvents.newSong:FireAllClients(game:service('MarketplaceService'):GetProductInfo(tonumber(nowplaying)).Name)
votes = {}
wait(120)
if "rbxassetid://"..nowplaying == "rbxassetid://"..thisfunctionssong then
makesong()
end
end
function countVotes()
local c = 0
for _,v in pairs(votes) do
if v[2] == true then
c = c +1
end
end
local remainder = #game.Players:GetPlayers() - #votes
local percent = (c + (remainder/2))/#game.Players:GetPlayers()
game.ReplicatedStorage.musicEvents.voteChange:FireAllClients(percent)
if percent <= skipratio then
--skip song
makesong()
end
return
end
game.ReplicatedStorage.musicEvents.voteYes.OnServerEvent:connect(function(p)
for _,v in pairs(votes) do
if v[1] == p.Name then
v[2] = true
countVotes()
return
end
end
table.insert(votes, {p.Name, true})
countVotes()
end)
game.ReplicatedStorage.musicEvents.voteNo.OnServerEvent:connect(function(p)
for _,v in pairs(votes) do
if v[1] == p.Name then
v[2] = false
countVotes()
return
end
end
table.insert(votes, {p.Name, false})
countVotes()
end)
game.Players.PlayerAdded:connect(function(Player)
Player.Chatted:connect(function(msg)
if Player:GetRankInGroup(Group) >= RequiredRank then
if msg == 'skipsong'or msg == 'skip song' or msg == 'skip' then
makesong()
end
end
end)
end)
game:GetService('MarketplaceService').ProcessReceipt = function(details)
for _, player in ipairs(game.Players:GetPlayers()) do
if player.userId == details.PlayerId then
if details.ProductId == productId then
game.ReplicatedStorage.musicEvents.addSong:FireClient(player)
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end
end
end
game.ReplicatedStorage.musicEvents.addSong.OnServerEvent:connect(function(p,id)
if tonumber(id) ~= nil and game:GetService("MarketplaceService"):GetProductInfo(tonumber(id)).AssetTypeId == 3 then
table.insert(requests, id)
end
end)
makesong()