Model falls through ground

This function “spawns” models. These models represent tools you can pick up.

local function dropGear(player, gearID, position) --gearID = some identifier name; position = HumRootPart position
	local droppedTemplate = gearMeshes:FindFirstChild(gearID)
	if droppedTemplate then
		local dropped = droppedTemplate:Clone()
		dropped.Name = gearID
		dropped.Type.Value = "dropped"
		dropped.DroppedBy.Value = player.Name
		dropped.PrimaryPart.Anchored = false
		dropped.PrimaryPart.CanCollide = true
		dropped.Parent = droppedFolder

		local char = player.Character
		local hrp = char and char:FindFirstChild("HumanoidRootPart")
		if hrp then
			local forward = hrp.CFrame.LookVector
			local dropPos = hrp.Position + forward * 3 + Vector3.new(0, 2, 0)
			local dropCFrame = CFrame.new(dropPos, dropPos + forward)
			dropped:PivotTo(dropCFrame) --spawns model in front of character
		else
			dropped:PivotTo(CFrame.new(position + Vector3.new(0, 3, 0)))
		end
		
	end
![image|543x340, 75%](upload://54lXTEf9zJvjLaW51lWXpnv55dD.jpeg)

	-- Remove from inventory
	local tool = player.Backpack:FindFirstChild(gearID) or player.Character:FindFirstChild(gearID)
	if tool then
		tool:Destroy()
	end
end

Sometimes it works fine but mostly the model just falls through the ground when I spawn it.

Somehow this is prevented by making sure the axe spawns vertically instead of horizontally:



This seems like a very unstable fix so I’m looking for safe solutions.

Hitbox is also the primary part

Could be something to do with a physics delay and how the physics engine might have not fully initalized the models collision yet
You could try to temporarily anchor and unachor after a slight delay with something like this:

dropped.PrimaryPart.Anchored = true
dropped.Parent = droppedFolder

dropped:PivotTo(dropCFrame)

task.delay(0.1, function()
	if dropped and dropped.PrimaryPart then
		dropped.PrimaryPart.Anchored = false
	end
end)

I hope this helps.

1 Like

If the position is even slightly inside of the ground, it may fall through. Try spawning the model upwards slightly.

Position is not even that close to the ground but it somehow still messes up

It happens less often now but stil occurs sometimes. Delaying it even more would probably work but that looks odd and there just has to be a better solution… Thank you though

Your script is only trying to enforce collidability on a single part in the Model, with dropped.PrimaryPart.CanCollide = true Have you looked at the PrimaryPart in the affected models? Like if someone made a tool with a tiny, invisible proxy or Handle part, like 0.1 x 0.1 x 0.1 or something, and the rest of the visible parts are CanCollide = false, it would be easy for the model to fall through the ground.

Also, you could turn on Show Decomposition Geometry in Studio Setting->Studio->Visualization and see what your collision geometry looks like for the affected models’ MeshParts. If the meshes are old, it’s possible that they have some bad or corrupt collision geometry. Setting collisionFidelity to Box and back to Default or Precise to regenerate the collision volumes can fix cases like this.

The primarypart is pretty much a hitbox covering both meshes. The mesh parts are cancollide false so does it even matter what collisionFidelity is? I tried it and it still didn’t work, thank you though.

A big, collidable hitbox should not be falling through terrain :-/ Like the only way in a simple Studio play test that I know to get this to happen is to deliberately do something weird, like serialized the Part with some high Part.Velocity or something. Unlikely to be the cause here.

Is the PrimaryPart falling through the world? Maybe make it visible and see? If it is, that’s really weird. I’m assuming you haven’t got any CollisionGroup filters set up to deliberately allow this to happen. If the PrimaryPart is staying above ground, and the MeshParts are not, then it would point to something being off about how the whole thing is welded together. The MeshParts are all welded to the PrimaryPart either directly, or hierarchically, right?

Why dont you use Align Orientation:

The best fix I could find is make the primaryPart / hitbox thicker and / or spawning it vertically. That way theres enough area for the physics to work properly. This is not an ideal fix and to me it seems unstable but hey at least it works now.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.