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

How to make a model loader with a textbox and a button?

local ID = script.Parent.Parent.IdHolder
local InsertService = game:GetService("InsertService") 

local Model = InsertService:LoadAsset(ID) 
local NewModel = Model:GetChildren()[1] 
NewModel.Parent = workspace 
Model:Destroy()
script.Parent.Parent.Display.Text = "Sucsess"

Its in a script in a gui how to fix this script my output error is

Unable to cast Instance to int64

3 comments

0

What is the type of IdHolder? Try using Parent.IdHolder.Value

0

Id holder is a textbox

0

I added .text but it still wont work

1 answer

✓ Accepted answer

Hello, hokyboy!

You just need to transform a string into a number with tonumber()

local ID = script.Parent.Parent.IdHolder.Text -- Getss the text
local InsertService = game:GetService("InsertService") 

local Model = InsertService:LoadAsset(tonumber(ID))  -- Transforms text into a number
local NewModel = Model:GetChildren()[1] 
NewModel.Parent = workspace 
Model:Destroy()
script.Parent.Parent.Display.Text = "Sucsess"

10 comments

0

Argument 1 missing or nil

0

Argument 1 missing or nil

1

what line?

0

20:40:17.878 - HTTP 404 (Not Found)

0

Line 4 is the issuse but i enabled https requests

0

The error is 404(not found) so it's probally invalid Asset id

0

For everything in my invectory doesnt work i tried the id and rbxassetid://(the id) It doesnt work for some reason

0

"The given asset must be created by you or Roblox, otherwise the function will error." - try using 257489726 as the asset, just to test

0

I fixed something but now i get BAD Request

0

Is any part of the script missing on the question? I think the error is when you're calling the script

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