EOASTUDIO
(EOASTUDIO)
April 20, 2022, 8:12am
#1
I want to achieve a plugin that inserts models (in this case car models) into the workspace.
The issue is that I don’t know how to do it.
I have tried scripting it on my own, searching on DevHub, Doc site, DevForum, YT and google.
Here would be what the plugin would do:
Click the button on the toolbar
A GUI will open
There will be a menu with different cars for you to add to the workspace
You click a car and select the design and the selected car gets inserted to the workspace
Pls help me on making this.
Everything woks except for the inserting part
Itequre
(ian)
April 20, 2022, 8:39am
#2
assuming the cars is models, you should check out InsertService ’s documentation; another way is to have the cars parented to the plugin’s script, and clone them into the workspace when the button is pressed. not sure if the second choice would work, but it’s worth a try
EOASTUDIO
(EOASTUDIO)
April 20, 2022, 9:55am
#3
These kind of tutorials drive me crazy…
EOASTUDIO
(EOASTUDIO)
April 20, 2022, 9:59am
#4
I don’t think that would work but I’ll try, could u script the clone script for me pls?
Itequre
(ian)
April 20, 2022, 10:07am
#5
local car1Id = YourCarModelId
MyPluginButton.Click:Connect(function()
local car1 = game.InsertService:LoadAsset(car1Id)
car1.Parent = workspace
end)
local car1 = script.MyCar
MyPluginButton.Click:Connect(function()
car1:Clone()
car1.Parent = workspace
end)
Try both, didn’t have the chance to do so. by the way, replace “car1Id” with your model’s asset and MyPluginButton with your plugin’s button.
1 Like
EOASTUDIO
(EOASTUDIO)
April 20, 2022, 10:11am
#6
Shouldn’t it be MyPluginButton.MouseButton1Click
?
Also, should this be in the plugin script or in the button’s localscript?
Itequre
(ian)
April 20, 2022, 10:13am
#7
According to Roblox’s “Intro to Plugins” article in the devhub, no; it should be Click. It should be in a ServerScript.
EOASTUDIO
(EOASTUDIO)
April 20, 2022, 10:13am
#8
Even if the button is inside a GUI?
Itequre
(ian)
April 20, 2022, 10:14am
#9
In that case, yeah, it should be MouseButton1Click; and it should be a LocalScript. Click should only be used on plugin buttons, not UI ones.
EOASTUDIO
(EOASTUDIO)
April 20, 2022, 10:23am
#10
Ok, lets revise:
local car1Id = MyModelId
script.Parent.MouseButton1Click:Connect(function()
local car1 = game.InsertService:LoadAsset(car1Id)
car1.Parent = workspace
end)
Script: The plugin script
PoliceCar: One of the car models
CarInserterPluginFolder: Where I keep all the plugin assets (the gui isn’t in there yet bc i haven’t finished the ui yet)
Should this be how it looks on the xplorer?
If not, where should I add the models?
Itequre
(ian)
April 20, 2022, 10:42am
#11
Yep, that’s how it should be. You can also use this to get the latest version instead of just the model:
local assetVersionId = game:GetService("InsertService"):GetLatestAssetVersionAsync(model_Id)
game:GetService("InsertService"):LoadAssetVersion(assetVersionId).Parent = game.Workspace