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

Inserting a Model with a id in a text box?

Asked by
danklua 72
3 years ago

So I made a gui that should insert a model (That I own which is also in my game) and i was trying to make the textbox replicated as the model id that will be inserted (the model would be one that I own or a free model) here's the script:

local id = script.Parent.TextBox.Text
script.Parent.TextButton.MouseButton1Click:Connect(function()
        local model = game:GetService("InsertService"):LoadAsset(id)
         model.Parent = workspace
end)

hopefully somebody could help!

0
It returns with an error "Unable to cast string to int64" danklua 72 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

You were giving it a string when it needed an integer, the tonumber turns it into a string if the string is a valid number else its nil,

local model = game:GetService("InsertService"):LoadAsset(tonumber(id))
Ad

Answer this question