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 its PrimaryPart?

I'm not sure if this is possible, but I was wondering if I could make a cloned model's y position always touch the ground. That probably doesn't make sense so let me explain: I want to make a clam's position spawn in the ocean in my game but the ocean has very uneven ground so if I just set a specific y position the clam, at times may look like it is floating. So I want to make it so that the clam always spawns on the ground. If someone could help me that would be greatly appreciated, thanks!

I've fixed my problem above but the only problem is the only part that moves is the PrimaryPart of the model which is TouchingPart but I don't know how I would move the entire model to the position of TouchingPart.

Here's my code so far:

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

Master i didn't get it aswell, if you have a script, post it so we can help better. So you are trying to clone a model into the surface of the ocean? Then you need to use :Clone to clone the model and set the position to it. Use Vector3 to set the position like: clam.Position = Vector3.new(position). Hope you understanded it! :)

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