Moving platform stops working after several rides

I built a moving platform (wooden square unanchored)


It takes the player across the river and to the other side, but after several back and forth movements the square gets caught on the bank.
Code:

To try to stop this problem, I messed around with the time of the wait and the position of the square but it still does this.

Thanks for reading

Instead of applying velocity you could probably tween it to the other side of the river.

1 Like

Would I just replace Vector3 with Tweenservice then?

Here’s how you would tween it

local tweenService = game:GetService("TweenService")

local motion = script.Parent

local tween = function(o, p, s, d, t)
    return tweenService:Create(o, TweenInfo.new(Enum.EasingStyle[s], ENum.EasingDirection[d], t), p)
end

local tween_0 = tween(motion, {CFrame = CFrame.new()}, "Linear", "InOut", 5) --make sure to replace CFrame.new() with the cframe of your choice as well as style, direction and time
tween_0:Play()
1 Like

You should use BodyMovers for this. BodyPosition to move the part, and BodyGyro keep its orientation stabilized.

Is there something wrong with tweens? Just wondering

When using tweens, you don’t move with the part thats being tweened. However, when using physics based movers, you can stand on and move with the part while its moving.

It’s also just a more simple solution.

Oh makes sense
[30 characters]

@KeysOfFate is correct in the sense that players do not move with the part that’s being tweened, but there is just a very simple fix.

You could use RunService to repeatedly run some come that raycasts down from the player y amount of studs, and check if that ray hits the moving part. Then you would take the CFrame of the part as soon as it hits and assign that value to a variable, you could then take the CFrame of the part once more and assign it to another variable (for arguments sake let’s call these variables pos1 and pos2 in sequential order). You could then multiply pos2 by an inversed pos1 and assign that to a new variable (let’s call this one pos3 of course). Now we can easily just assign pos1 the new CFrame value for the moving part. And lastly we can set the CFrame of the players HumanoidRootPart to pos3 multiplied by the CFrame of the HumanoidRootPart itself.

But for the sake of simplicity, yes just use BodyMovers as suggested by @KeysOfFate.

1 Like

Thank you all for your help!
I found an old Roblox video that helped me out: