Model doesnt anchor

I made a short script so it spawns a random gun of a folder and anchors it.

The issue is that it doesnt let me anchor/un anchor it so I need help because it doesnt give me any errors, it just doesnt let me do it.

code:

local workspace = game.Workspace
local guns = game.Workspace.FolderGuns:GetChildren()
local click = script.Parent.ClickDetector

click.MouseClick:Connect(function()
	local randomNum = math.random(1, #guns)
	local gun = guns[randomNum]
	local gunP = gun:Clone()
	gunP.Parent = workspace
	local ModelToMove = gunP
	local songun = gunP:GetChildren()
	ModelToMove:MoveTo(Vector3.new(-17.111, 8.145, 16.19))
	songun.Anchored = true
end)

In need some help please.

your songun is a table you should try this instead of songun.Anchored = true

for i,v in ipairs(songun) do
     v.Anchored = true
end
3 Likes

Hak beat me to it :stuck_out_tongue: but I would like to add, maybe use :PivotTo() , instead of :MoveTo() if you are wanting it to move to the exact position and not worry about any collisions with things.

1 Like

ok but where do i put that part?

Also you could add the @SelDraken suggestion too

2 Likes

its working good but it has a problem, the parts of the gun goes crazy and doesnt stay together

I had to make welds so they stay together