Hi. In order to do that, you need to pass the model id to the server via RemoteEvents, as only server can insert assets into the game. (If you don't know how remote events work, you should read about Filtering Enabled here, and about remotes themselves here)
I'm going to assume you want to insert models of the ids you type into a TextBox in some gui.
To do that, create a remote event under ReplicatedStorage, name it as you wish, but I'll just call it "RemoteEvent", and then use it to pass the model id to the server once the player clicks your button. Example:
LocalScript
local remote = game.ReplicatedStorage:WaitForChild("RemoteEvent")
local gui = script.Parent
local button = gui.Button
local tb = gui.TextBox
button.MouseButton1Click:Connect(function()
remote:FireServer(tb.Text)
end)
Server Script
local remote = game.ReplicatedStorage.RemoteEvent
remote.OnServerEvent:Connect(function(plr, id)
local model = game:GetService("InsertService"):LoadAsset(id)
model.Parent = workspace
end)
Don't forget to implement a proper security against exploiters. Also be aware of the restrictions when it comes to inserting models (you can't insert models that aren't in your inventory or don't belong to roblox).
6 comments
And I copy and pasted the first line from the roblox wiki because I'm not really experienced with scripting.
is it local?
nope.
it should be local
k. Lemme test it.
and when its local, its not working.