How to make moving platform that sticks to you

I have a script that moves a platform but it doesnt move the player with it.

local TweenService = game:GetService("TweenService")
local Time = 2

coroutine.resume(coroutine.create(function()
	while true do
		TweenService:Create(script.Parent, TweenInfo.new(Time, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut),{Position = script.Parent:FindFirstChild("end").Position}):Play()
		task.wait(Time)
		TweenService:Create(script.Parent, TweenInfo.new(Time, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut),{Position = script.Parent.start.Position}):Play()
		task.wait(Time)
	end
end))
2 Likes

The way I’d go around doing this is by changing the AssemblyLinearVelocity or using LinearVelocities to move it. Definitely not the best way to do it, but it works.

1 Like

If you don’t want to use bodymovers like @7booooy mentioned, the only realistic way to do this while using TweenService is to also move the player’s HumanoidRootPart in unison with the platform on the client:

2 Likes

You can use physics to solve this problem as using physics constraints will handle player movement for you. For this reason, if your intended feature is able to use physics constraints you should absolutely use those to save you some time. One particular physics constraint I recommend to use is the Prismatic Constraint. It’s good for moving platforms.

If your intended feature is too complex, then you should check out the link @bongusbingis shared. It has some useful info on how to update player positions with scripting.

@7booooy The issue with this is that LinearVelocity doesn’t allow the player to move while in affect unlike VectorForce. VectorForce is not as precise so overall velocity/force instances will be more difficult to use.

1 Like

Nope. Use TweenService on an Anchored Part, but weld an unanchored platform to it that the player can stand on. Since the unanchored platform is now a physics item the player will move with it.

@0ElonMuskEnjoyer0 there are so many posts on the forums that would have solved your issue if you’d used the Search tool up top.

As @thegreatdabb said you can easily use a PrismaticConstraint. Here’s a model I made to show people how to set them up, but you can rebuild it and code it the way you want it to move:
https://create.roblox.com/dashboard/creations/store/7645980152/configure

2 Likes

This still involves utilizing an unanchored part as a solution – creating a solution that can be configured to automatically apply everywhere in your game as needed, without having to repeatedly weld two objects together, will arguably work better in a lot of cases and save OP time in the long run if he has 20 moving platforms, for example.

1 Like

If you just want the character to stay on the platform, you simply have to move it using physics. You can do this by unanchoring the platform and tweening an AlignOrientation and an AlignPosition.


If you actually want the character to follow the moving platform, even in the air, you’ll need to program something custom or use the character controllers below:

You can try out the new beta character controller, which has this feature:

You can also use one of EgoMoose’s controllers without the gravity modifier, though I forget which supports this:

Here is tutorial of what you try to achieve: Jailbreak train platform system? - #35 by Kord_K