In my game, I have a platform that moves by being tweened on the client. I want to make it move players along with it via a script I found in some other topics. (attached)
However, the platform displays unexpected behavior by drifting the player, and pushing them off the platform like in this video
I want the player to stay on the platform without being drifted off. I have read many other devforum topics and have not found anyone experiencing this.
1 Like
From what I can tell, you’re adjusting a player’s character’s cframe by multiplying it by how much the platform’s tween changes the platform’s own position. Instead of using cframes, I would’ve used vector3s instead, since they’re far more flexible with arithmetic and are all you need when it comes to position. All you’d need to do then is to just figure out the adjustment between the last heartbeat and apply it to the humanoid root part. Implementing it might look something like changing relativecframe
to currentCframe.Position - lastCframe.Position
.
I highly recommend just using AssemblyLinearVelocity for this. Just set the property AssemblyLinearVelocity of the platform to the direction it is moving. Learn more about this property here: https://create.roblox.com/docs/reference/engine/classes/BasePart#AssemblyLinearVelocity.
I also suggest using the following event to set the property every time this event is triggered, because it fires before the physics simulation is calculated:
game:GetService("RunService").PreSimulation
.
Many people believe that CFrame is more performant than physics, which is NOT the case. Here is proof: https://www.youtube.com/watch?v=thfUspopuGE