Hello
Im making npc thatll drop chest parts when dead
Problem is that is has few meshes and i cannot merge them. Whole chest is in a model, i can copy model but i cannot move it as a whole. Now i try to scope all children but it doesnt help at all
here is the script:
Humanoid.Died:Connect(function()
local chest= game.ReplicatedStorage:FindFirstChild("chest"):Clone()
chest.Parent = game.Workspace
local allparts = chest:GetChildren()
allparts.Position = head.Position -- for some reason i cannot scope "position" to them
end)
That is because when you use :GetChildren(), you get returned a table value. In order to make your script work, all you have to do is loop through all the instances in the table and set their positions one by one.
Example:
...
local allParts = chest:GetChildren()
for i, part in allParts do --//this will loop through all the instances one by one
part.Position = head.Position
end
end)
You can use Pivot to move a whole model as one object, it only takes a CFrame value, so either head.CFrame, or head:GetPivot(), it can’t take only a position which is Vector3 and not CFrame.