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

Gear giving gui is not working and displays 'Unable to cast string to int64' in output. Why?

So I've been trying to make a gear gui where the play can put in an ID from the gear catalog to give them the gear they want. The problem is that whenever said player attempts to put in an ID, the output displays 'Unable to cast string to int64', and will not spawn in that item.

wait(1)
script.Parent.TextButton.MouseButton1Click:Connect(function()
	local insertservice = game:GetService("InsertService")
	local item = insertservice:LoadAsset(script.Parent.TextBox.Text)
	item.Parent = workspace
end)

Any suggestions, tips, or explanations as to why my script isn't working is greatly appreciated!

1 comment

0

Is this suposed to give the player gear based on a id? If so try using this: tonumber("text here")

1 answer

Hello. The problem is that when getting text from a TextBox, the text is a string, not an Int64. To fix this, use the tonumber() global.

wait(1)
script.Parent.TextButton.MouseButton1Click:Connect(function()
    local insertservice = game:GetService("InsertService")
    local item = insertservice:LoadAsset(tonumber(script.Parent.TextBox.Text))
    item.Parent = workspace
end)

2 comments

0

Hello! Thanks for the tip, but when running the script again, the output is now saying "Argument 1 missing or nil".

0

Is it a LocalScript? If it isn't then use a LocalScript and set "AllowClientInsertModels" to true.

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