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

What is a model's Parent after being loaded in using InsertService?

Asked by 6 years ago

In this script, I am trying to determine if the model is already in the player's workspace (not workspace, though, because that's not exactly where models from InsertService go). But I need to know where they actually go so I can change line 5 when it's looking the object.

model=game:GetService("InsertService"):LoadAsset("892228363")

function onTouched(hit)

local found = game.Workspace:FindFirstChild("model")
if found then 
    print("already here")
else
model.Parent=game.Workspace
end 
end
workspace.touchthis.Touched:connect(onTouched)

Thanks <]:^)

1 answer

Log in to vote
0
Answered by 6 years ago

The parent of insertservice is Model. So you can just Model:GetChildren() and parent all of that to the desired place. Also with the local variable 'found' when it's being inserted it uses a capital 'm' so it would be

model=game:GetService("InsertService"):LoadAsset("892228363")

function onTouched(hit)

local found = game.Workspace:FindFirstChild("Model")
if found then 
    print("already here")
    for I,v in pairs(found:GetChildren()) do
    v.Parent = where_ever_you_want_to_put_it
end
else
model.Parent=game.Workspace
end 
end
workspace.touchthis.Touched:connect(onTouched)

Also InsertService will not work if you don't own the place and the model you are trying to insert is not in your inventory. But if it's gear then you would no problem.

Ad

Answer this question