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

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

Asked by 4 years ago

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!

0
What line is that error on? I see two possible places that might be erroring. moo1210 587 — 4y
0
Line 1 mahid786 41 — 4y
0
Do you have a string value. JesseSong 3916 — 4y
0
i dont believe i do? do you mean in the TextBox Where The ID Goes? mahid786 41 — 4y
View all comments (2 more)
0
Yes JesseSong 3916 — 4y
0
then yes i do. mahid786 41 — 4y

1 answer

Log in to vote
0
Answered by
cegberry 432 Moderation Voter
4 years ago
Edited 4 years ago

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)
0
im getting another error now on line 7 *attempt to concatenate string with table* mahid786 41 — 4y
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! cegberry 432 — 4y
0
It Works Thanks Alot! mahid786 41 — 4y
Ad

Answer this question