Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why am I receiving the error "Unable to cast string to int64" and what does it mean?

Asked by
Hypoxla 125
4 years ago

I am trying to make a server-side music system, but MarketplaceService doesn't properly work.

Script:

game.ReplicatedStorage.MusicSystem.NewSong.OnClientEvent:Connect(function(music)
    progres.Size = UDim2.new(0,0,1,0) 
    local song = game.Workspace.SoundSystem.Music.SoundId
    local asset = game.MarketplaceService:GetProductInfo(song) -- This is the line the Error is on.

    songName.Text = asset.Name
    progres:TweenSize(UDim2.new(1,0,1,0),'Out','Linear',(song.TimeLength)-1)
end)

Error: Unable to cast string to int64

Sometimes the error doesn't show up at all.

1 answer

Log in to vote
1
Answered by 4 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.
local asset = game.MarketplaceService:GetProductInfo(tonumber(song), Enum.InfoType.Asset) 

Try this, your SoundId may be returning a string. I believe you also need to declare an InfoType, AKA GamePass, Dev Product, etc.

https://developer.roblox.com/en-us/api-reference/function/MarketplaceService/GetProductInfo source ^

Ad

Answer this question