Unable to Cast String to INT64 | Request Music Player

So I am having an error where it says, [Unable to Cast String to INT64]. Here is the part of the code that I think is messing up:

script.AddCustomSong.OnInvoke = addcustomsongfunction

local function playNext()
if db == false then
db = true
sound.Playing = false
sound.SoundId = “”
wait(.7)
sound.TimePosition = 0
local chosen = nil
local dj = nil
if #requestedSongs > 0 then
chosen = requestedSongs[1]
dj = requestedNames[1]
table.remove(requestedSongs,1)
table.remove(requestedNames,1)
else
repeat chosen = songs[math.random(1,#songs)] until chosen ~= lastsong and chosen ~= nil and ms:GetProductInfo(chosen).Name:lower()~=“(removed for copyright)” and ms:GetProductInfo(chosen).Name:lower()~=“[ content deleted ]”
dj = “SERVER”
end
sound.SoundId = “rbxassetid://”…tostring(chosen)
sound.Playing = true
currentsong = chosen
currentdj = dj
lastsong = chosen
local info
local success, result = pcall(function()
info = ms:GetProductInfo(chosen, Enum.InfoType.Asset)
end)
update:FireAllClients(chosen,dj,info.Name)
resettrellolist()
db = false
end
end

playNext() – startup

sound.Ended:Connect(function()
playNext()
end)

Please format your code correctly, I can’t read that.

Nevermind, I did it myself.

CODE

script.AddCustomSong.OnInvoke = addcustomsongfunction

local function playNext()
  if db == false then
    db = true
    sound.Playing = false
    sound.SoundId = “”
    wait(.7)
    sound.TimePosition = 0
    local chosen = nil
    local dj = nil
    if #requestedSongs > 0 then
      chosen = requestedSongs[1]
      dj = requestedNames[1]
      table.remove(requestedSongs,1)
      table.remove(requestedNames,1)
    else
      repeat chosen = songs[math.random(1,#songs)] until chosen ~= lastsong and chosen ~= nil and ms:GetProductInfo(chosen).Name:lower()~="(removed for copyright)" and ms:GetProductInfo(chosen).Name:lower()~="[ content deleted ]"
        dj = “SERVER”
      end
      sound.SoundId = “rbxassetid://”…tostring(chosen)
      sound.Playing = true
      currentsong = chosen
      currentdj = dj
      lastsong = chosen
      local info
      local success, result = pcall(function()
      info = ms:GetProductInfo(chosen, Enum.InfoType.Asset)
      end)
      update:FireAllClients(chosen,dj,info.Name)
      resettrellolist()
      db = false
    end
  end

  playNext() – startup

  sound.Ended:Connect(function()
  playNext()
  end)

I assume “chosen” is a string. It needs to be a number.

You put 3 ‘.’’s. Try printing the type of what you’re using for the sound id.

Oh, is it supposed to be 2? 3030303

The concatenation operator is supposed to be 2 dots (.), yes, but I may see an issue here:

I’m lead to believe that this is where the error occurs, since asset ids are 64-bit integers. From the error, I can tell that your table’s entries are strings instead of numbers, so you should change them to numbers


Not really worth mentioning, but when using the 2 dots, when concatenating a number, it converts it to a string