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

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

Asked by
hokyboy 270 Moderation Voter
4 years ago
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

0
What is the type of IdHolder? Try using Parent.IdHolder.Value Leamir 3138 — 4y
0
Id holder is a textbox hokyboy 270 — 4y
0
I added .text but it still wont work hokyboy 270 — 4y

1 answer

Log in to vote
2
Answered by
Leamir 3138 Moderation Voter Community Moderator
4 years ago

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"
0
Argument 1 missing or nil hokyboy 270 — 4y
0
Argument 1 missing or nil hokyboy 270 — 4y
1
what line? Leamir 3138 — 4y
0
20:40:17.878 - HTTP 404 (Not Found) hokyboy 270 — 4y
View all comments (6 more)
0
Line 4 is the issuse but i enabled https requests hokyboy 270 — 4y
0
The error is 404(not found) so it's probally invalid Asset id Leamir 3138 — 4y
0
For everything in my invectory doesnt work i tried the id and rbxassetid://(the id) It doesnt work for some reason hokyboy 270 — 4y
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 Leamir 3138 — 4y
0
I fixed something but now i get BAD Request hokyboy 270 — 4y
0
Is any part of the script missing on the question? I think the error is when you're calling the script Leamir 3138 — 4y
Ad

Answer this question