Parts slowly descending into the void

I am trying to make a model placement system where you select a model and then it shows up allowing you to place it anywhere. I’ve searched as much as I can but I can’t find anything.

https://www.youtube.com/watch?v=ya8gRYmPRFQ

This is a vide of my issue, as you can see it is slowly descending into the void.

Here is my script:

game.ReplicatedStorage.RemoteEvents.DecoySpawn.OnServerEvent:Connect(function(player, propName)
	game.ReplicatedStorage.Placing.Value = true
	game.ReplicatedStorage.PropName.Value = propName
	local clone = game.ReplicatedStorage.Props:FindFirstChild(propName):Clone()
	for i, v in pairs(clone:GetDescendants()) do
		if v then
			if v:IsA("Part") then
				v.CanCollide = false
				v.Transparency = 0.5
			end
		end
	end
	while true do
		wait(0.01)
		if game.ReplicatedStorage.Placing.Value == true then
			local movePart = clone:FindFirstChild("MovePart")
			local character = player.Character
			local HumanoidRootPart = character:FindFirstChild("HumanoidRootPart")
			clone.Parent = game.Workspace.Following
			
			movePart.CFrame = HumanoidRootPart.CFrame * CFrame.new(0,0,-30) -- This might be where the error is occuring.
		else
			break
		end
	end
end)

1 Like
1 Like

Multiplying the CFrame would move it, not set it. You should be constructing a new CFrame with the components you want instead.

Something like

movePart.CFrame = CFrame.new(HumanoidRootPart.CFrame.Position.X, HumanoidRootPart.CFrame.Position.Y, HumanoidRootPart.CFrame.Position.Z - 30)

(Hopefully I remembered correctly on how you create CFrames lol)

2 Likes

It’s still descending when I tried this script. It also seemed like it was trying to stay level because it was twitching.

1 Like

In that case, are you sure you anchored the parts?

1 Like

So the only part I anchored was the PrimaryPart of the model which is labeled as “movePart” in the script. Everything else is welded together to the movePart.

2 Likes

I don’t believe thats the issue. The model itself shouldn’t have to rely on collision with the baseplate to stay at where its supposed to.

As for OP, perhaps try using model:moveTo instead? (it also accepts a CFrame, it just moves a model instead of a basepart)

I remember encountering a similar issue before, but I can’t seem to find how I solved it.

(also, what is game.Workspace.Following?)

2 Likes

Maybe you’re right, but he can still try and see if makes a difference. I made a placement system like his one before and it did not sink into the ground even when CanCollide was false.

3 Likes

I tried what you said by making CanCollide false and the model flung out of the map. I also would not like it to be on because there will be other stuff on the map other than what you place.

I see you have a part called MovePart in your model, is this the part which’s position you are editing with your mouse?

1 Like

Ok so I took a look at some old code I made, and the only two difference I could notice was that first, I used model:PivotTo() for models, and that secondly, I used a RenderStepped:Connect() instead of a while true do.

I also didn’t re-get the part im moving, the character, and the HRP, and instead just kept their references.

How to make part "collide" when dragged by mouse (post containing my code, if you want to see)

1 Like

I don’t believe OP’s system relies on the mouse. It looks like a more basic placement system which relies on the location of the player.

1 Like

Fair point, however I used raycasting with mouse.UnitRay to get the position to move my model to with ray.Position

2 Likes

The models position isnt changed with the mouse. My goal is to make it directly infront of your character so you can align it perfectly how you want. But yes, MovePart is the part I am moving, its also the PrimaryPart in the model.

I’ve never tried using PivotTo() so is this how you were saying I should use it? clone:PivotTo(CFrame.new(HumanoidRootPart.CFrame.Position.X, HumanoidRootPart.CFrame.Position.Y, HumanoidRootPart.CFrame.Position.Z - 30))

1 Like

Are you using Welds or WeldConstraints? I think the offset of Weld’s change when you set a parts CFrame. WeldConstraints may fix your issue, or maybe PivotTo would work with Welds.

On the WeldConstraints Dev docs:
“If a welded part’s CFrame is updated, that part will move and all of the connected parts will also move, ensuring they maintain the same offset as when the weld was created.”

I was using a mix of both because thats whatever my weld plugin did, I’ll replace all the welds with weld constraints and see what happens.

1 Like

@greenboo5 probably identified the correct issue, in which case simply doing PivotTo should work, as PivotTo moves the entire model, not just a single basepart. (If it doesn’t work, you could always remove the welds. That should absolutely work considering I’ve literally done that)

Thank you it worked perfectly.

1 Like

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