Unable to cast string to int64

Hello everyone, i had this script for an old game. It’s parented to a textbutton and an inputbox where the player could insert and ID and get that item, but now that i need this script again, my output reports “Unable to cast string to int64”, not really sure what happened but it worked fine a while ago.

local Button = script.Parent
local Player = game.Players.LocalPlayer

function insert()
local ID = script.Parent.Parent.InputBox.Text
local Object = game:GetService("InsertService"):LoadAsset(ID)
Object.Parent = game.Workspace
Object:MoveTo(Player.Character.Torso.Position)
end

script.Parent.MouseButton1Down:connect(insert)

I’ve never used InsertService before but, are you sure it’s supposed to be a string and not a number.
If it’s supposed to be a number then do:

:LoadAsset(tonumber(ID))

ABOVE, I do not know if this is the issue.

And please use :Connect() because :connect() is deprecated.

Edit:
Oh, I was correct:

An error that will appear when you click:

It only works on the server.

So i need to fire a server event?

The text is a string, you’ll need to use tonumber() on it.
And yes, you also need to set up a remoteevent as the server deals with this kind of stuff (:LoadAsset().)

1 Like

Yes, if you want you can make the script place the object in the player’s Backpack so that only the player can take it.