I have a part that is constantly being updated to match another part’s X and Z CFrame values, which are constantly being tweened to different, random positions. Due to the nature of the .Touched method, I cannot just weld the first part to the second part due to its position being tweened. However, because the first part’s CFrame is constantly being changed, it deletes itself. I have streaming enabled turned off, so it can’t be that. I have also made sure that the part is being deleted on the server and on the client. If I remove the code that updates the CFrame, the part does not get deleted. If anybody knows a workaround or a way to fix this, I’d greatly appreciate it.
I’m not sure why your part is getting deleted, but if you want to constantly update a part’s CFrame to match another’s, use AlignPosition and AlignOrientation, it doesn’t need code and it may fix the problem.
Is it anchored? Maybe it’s just falling through the map and being destroyed.
And if you do prefer to hard code this instead of using the AlignPos/Orientation objects. You should do so by connecting to RunService Heartbeat.
I was thinking the same thing, but even if it wasn’t anchored it shouldn’t fall out of the map because it’s CFrame is constantly being set to the other part’s CFrame.
It very well could if in a split moment the object stops colliding with the terrain or map floor. I’ve had this happen plenty of times. If he’s not utilizing any of the roblox physics and only manually changing the CFrame then it should be anchored.
Just for clarity. Is this client or server side? And if its client side does the client have network ownership? If the part is not only supposed to be visible by the client, then make sure its created by the server first.
Sorry for the late reply everyone, I was super busy yesterday! I got the part to stop deleting itself by using AlignPosition and AlignOrientation (I decided that it’s better for performance), but now the part only snaps to the tweening part after the tween. Anybody know how to fix this? I got this behavior by turning RigidityEnabled and ReactionForceEnabled to true. Otherwise, nothing happens at all and the part falls into the void because it’s collision is off.
You probably will find that its better to just do this manually using heartbeat and anchoring the part. Performance wise I highly doubt its much difference in performance and honestly may even be more efficient. The alignment objects are just doing the same thing anyway behind the scenes but they include other code/checks etc… that you probably don’t even require. Doing it manually just gives you more control over exactly what happens.
Something like this:
local somePart = <partToMatch>
local killPart = <partMatching>
game:GetService("RunService").Heartbeat:Connect(function()
local pos = somePart:GetPivot().Position
local newPos = Vector3.new(pos.X, killPart:GetPivot().Position.Y, pos.Z)
local newCF = CFrame.new(newPos)*CFrame.Angles(0,0,math.rad(90))
killPart:PivotTo(newCF)
end)