How to make a player stick to a tweened part?

It sounded simple to me, but I couldent understand it. I want to make a player move along with a moving part whenever the player is ontop of it.

I looked at other solutions, but it looks like theres just so many solutions for diffrent purposes, and it looks very complex. Im very stuck on where to even start.

I only want the player to stick on the part while standing on it, when they jump they should stop sticking

If anyone wonders what my current script is, its just a basic moving script with waypoints:

local t=script.Parent.Time.Value
local Tween_Settings = TweenInfo.new(t,Enum.EasingStyle.Sine,Enum.EasingDirection.Out,-1,true)
local WP1 = script.Parent:WaitForChild("Waypoint1")
local WP2 = script.Parent:WaitForChild("Waypoint2")
local MP = script.Parent:WaitForChild("Moving")
WP1.Transparency = 1
WP2.Transparency = 1
MP.Position = WP1.Position
local TS = game:GetService("TweenService")
TS:Create(MP,Tween_Settings,{Position=WP2.Position}):Play()

I was actually having the same problem as you somewhere around a week ago. After searching for longer than 10 seconds, I decided to use AlignPosition.

AlignPosition moves your character using Roblox physics, as if you just set the CFrame, it won’t interact with the character. You can just drop it in into the properties table of TweenService:Create()after creating the attachments when the character gets added.

I used this code for my moving platform:

local LastPosition = Platform.Position
local CurrentPosition
local DeltaPosition
local Velocity

local Loop
	Loop = RunService.Heartbeat:Connect(function(deltaTime)
		if MovingPlatform.Parent == nil then Loop:Disconnect() end
		CurrentPosition = Platform.Position
		DeltaPosition = CurrentPosition - LastPosition

		Velocity = DeltaPosition / deltaTime
		Platform.AssemblyLinearVelocity = Velocity
		LastPosition = CurrentPosition
	end)

You have to run it on the client side. It does not work when resizing the part though. As ryanzhzh said you can also use AlignPosition.

Alright I’ll try this soon but just to make sure i understand it, I connect with the players root attachment (or whatever it’s called I forgot) to the align position when it touches the part. Then I disconnect the attachment once it stops touching the part.

Beware though: it can still interact with other parts blocking you. I guess you can use CollisionGroups though.

Question: What do you mean by interact with other parts?

Basically, AlignPosition interacts with physics. That means moving the character, and being forced to move around parts.

This following video is what I mean using my implementation of the moving platforms (the system’s kinda like yours). The video’s fast because Roblox didn’t like me uploading something longer.

To fix it, you’d have to create a collision group for the moving platform and disable collisions with all other collision groups shown in the Collision Groups Editor, and create a new collision group for all the parts in a character every time Player.CharacterAdded is fired.

Ok thank you for saying that
im going to try and add this now and ill see if it works

Im having trouble getting the Align position to actually work, Can you help me with the values for it? Thank you

Here was the setup for my moving platforms, edited to exclude the AlignOrientation part:

local attachment = Instance.new("Attachment", platform)
local alignPosition = Instance.new("AlignPosition")
alignPosition.Position = platform.Position
alignPosition.Attachment0 = attachment
alignPosition.Mode = Enum.PositionAlignmentMode.OneAttachment
alignPosition.RigidityEnabled = true
alignPosition.Parent = platform
platform.Anchored = false

Oh ok I understand it now! thanks for helping me!

btw RigidityEnabled seems to NOT move the player on further testing (today) so remove the line that sets that

I just came across that issue like a week ago so i reversed it

oh alr

first time hitting the char limit can’t wait to do it for the rest of my life