So Im Trying To Make My Music Gui Show What Is Currently Playing When They Press Play With The ID In The Text Box But Its Not Working, Here Is The Script:
local Music = game:GetService("MarketplaceService"):GetProductInfo(script.Parent.Parent.IDhere.Text) local ID = script.Parent.Parent.IDhere script.Parent.MouseButton1Click:Connect(function() if string.len(ID.Text) > 0 then script.Parent.Text = '...' wait(1) script.Parent.Text = 'Playing: ' ..Music else script.Parent.Text = 'Error: No ID Found' end end)
I Also Keep Getting This Error Unable to cast string to int64. Can Someone Please Help Me Im Stuck And Dont Know What To Do. Thanks!
The most likely reason why it doesn't work is, it only checks the TextBox once
You can transfer the line local Music = game:GetService("MarketplaceService"):GetProductInfo(script.Parent.Parent.IDhere.Text)
just underneath script.Parent.MouseButton1Click:Connect(function()
This will make it, so the script will check the TextBox every time that the TextButton is clicked, this should also apply to your ID variable, as it only checks it once
Unable to cast string to int64
This means that the script attempted to give something a string, but it has expected a int64, which is a number that can go negative and positive, and up to the number
2 ^ 64 - 1
To fix this you'd want a number input, not a string input, meaning if a sound id is 123, you'd want to put in the number 123, not the string "123" or the string "rbxassetid://123", since the most likely thing you are experiencing is the string "123", you'd want to put a tonumber to transform a string to a number, therefore your code shall be:
script.Parent.MouseButton1Click:Connect(function() local Music = game:GetService("MarketplaceService"):GetProductInfo(tonumber(script.Parent.Parent.IDhere.Text)) local ID = script.Parent.Parent.IDhere if string.len(ID.Text) > 0 then script.Parent.Text = '...' wait(1) script.Parent.Text = 'Playing: ' ..Music else script.Parent.Text = 'Error: No ID Found' end end)