Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can I move a model to it's PrimaryPart?

I have a system where I clone a model and then detect if the PrimaryPart which is "TouchingPart" is being touched by anything, if that is nil then it moves down 1 stud and repeats the process until it is touching something. The only problem is it that it only moves the PrimaryPart and not the entire model itself. So I'd like to know how to move a model to it's PrimaryPart. I've been having this issue for a long time now and I don't know how to fix it. If someone could help me that would be great!

Code:

game.Workspace.Clams["Closed Clam"].HasPearl.Value = false

	
if game.Workspace.Clams["Closed Clam"].HasPearl.Value == false then
	game.Workspace.Clams["Closed Clam"].HasPearl.Value = true
	local Clam = game.Workspace.Clams["Open Clam"]:Clone()
		
	Clam.Parent = workspace
	Clam:MoveTo(game.Workspace.Clams["Closed Clam"].PositionPart.Position)
		
	game.Workspace.Clams["Closed Clam"]:Destroy()
		
	local TouchingParts = Clam.TouchingPart:GetTouchingParts()
		
	if not TouchingParts then
	repeat Clam.TouchingPart.Position = Clam.TouchingPart.Position + Vector3.new(0,-1,0) until TouchingParts ~= nil
	end
	Clam:MoveTo(Clam.PrimaryPart.Position)
	print("Worked")
end

1 answer

This discussion is preserved as it was. New answers, comments, and votes are closed.