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

I'm trying to make a textbox that whenever you enter a model id it puts it in your game?

local is = game:GetService("InsertService")
local button = script.Parent
local text = button.Text

is:LoadAsset(text).Parent = workspace

the error is 'Unable to cast string to int64'

2 comments

0

You forgot to add a function that runs only when user is done typing

0

I think the error means that tonumber is required for this to work, try putting on line 5

2 answers

LoadAsset requires an integer as input:

local is = game:GetService("InsertService")
local button = script.Parent
local text = tonumber(button.Text)

is:LoadAsset(text).Parent = workspace

3 comments

0

wont work

0

but i gave up on it im making something new

0

Ok

You may want or not want to see this but if you still want to do this,remember that the player cant communicate with the server without a Remote Event! Also remember that the service only instances a model owned by the game creator or ROBLOX

Insert a script in ServerScriptService,and a remote event called "InsertModel" on ReplicatedStorage

game.ReplicatedStorage.InsertModel.OnServerEvent:Connect(function(player,ID)
	local InsService = game:GetService("InsertService")
	local TheID = ID
	
	InsService:LoadAsset(TheID).Parent = workspace
end)

In StarterGui,Insert A ScreenGui called "InsertGui." There,Insert 2 things more,A textButton called "Button", and a TextBox called "IdType." Insert a LocalScript on the Button:

script.Parent.MouseButton1Click:Connect(function()
	game.ReplicatedStorage.InsertModel:FireServer(script.Parent.Parent.IdType.Text)
end)

I tried it and it works,even without the tonumber(),but if it doesnt work you can add it to the server script tonumber(ID)

Hope it helps! Never give up to reach your beloved dreams!

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