Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Im Trying To Make My Music Gui Show What Is Currently Playing But Its Not Working?

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!

6 comments

0

What line is that error on? I see two possible places that might be erroring.

0

Line 1

0

Do you have a string value.

0

i dont believe i do? do you mean in the TextBox Where The ID Goes?

0

Yes

0

then yes i do.

1 answer

✓ Accepted answer

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)

3 comments

0

im getting another error now on line 7 attempt to concatenate string with table

0

Ah sorry about that, GetProductInfo returns a table, not a name, this table contains the information to the asset id you gave it, to fix it, replace Music on line 7 with Music.Name, for more information go to: https://developer.roblox.com/en-us/api-reference/function/MarketplaceService/GetProductInfo , if this worked, please accept my answer thanks!

0

It Works Thanks Alot!

This discussion is preserved as it was. New answers, comments, and votes are closed.