Help With Moving Part(with player on it)

Hello, i need help with my Moving Platform Script:

I want to make it go one side and wait some time and return to the start position

here’s the script:

local Time = time()

script.Parent.Velocity = script.Parent.Velocity + Vector3.new(2,0,0)

	
game:GetService("RunService").Stepped:connect(function()
		
	script.Parent.CFrame = script.Parent.CFrame+Vector3.new((time()-Time)*2,0,0)

	Time = time()

end)

Change “Stepped” to “RenderStepped”

if it still doesn’t work, do this:


script.Parent.Velocity = script.Parent.Velocity + Vector3.new(2,0,0)

game:GetService("RunService").Stepped:connect(function(deltaTime)		
	script.Parent.CFrame = script.Parent.CFrame+Vector3.new((time()-deltaTime)*2,0,0)
end)

Its not moving now at all just stuck in the place

ok sorry i can’t help you but 1 last thing, if have 0 values in the bodymover that you are adjusting, replace it with positive numbers.

1 Like

Have you tried just using tweenservice?
I dont usually recommend this but this is very easily implementable with tweenservice and requires like 1 line of code

i didn’t tried that but can you show me example please?
i will appreciate it a lot

also i want to remind that i want player to stay on the part and move with the part.

You should probably use bodymovers then, its very hard to make the player move with the part without a physics based thing

You could just set the position of a body position to something, wait a while, then set the position to the original position
Thatd also be relatively easy

CFraming a Part only changes the Position of that Part, it doesn’t really move it so a player won’t ‘feel’ the effect of the Part jumping from Position to Position underneath them.
As @PapaBreadd stated, try using a physical approach like Mover Constraints | Roblox Creator Documentation or a PrismaticConstraint | Roblox Creator Documentation.

hi, I tried to search and read about what you said and I still can’t understand how to do it can you please help me and make an example rbx file?

i will appreciate it a lot.

You can go to the Constraints section of the Model tab at the top of the page in Studio.
Click Constraint Details and Draw On Top from the tools there.

Select the Create tool then choose Prismatic Constraint from the drop down menu and click on any Anchored Part in your place (try to choose a surface facing the direction you want the platform to travel) to place your first Attachment. It doesn’t have to be at the end of the travel of the platform, but it usually helps. Then click on your platform to place your second Attachment. Make sure your platform has the Anchored checkbox selected off!

Select each Attachment and make sure the orange and yellow arrows are facing the same direction on both. If not you can use the Rotate tool on the Attachment to rotate it to align the directions. If the Attachments don’t align don’t worry, I usually select one of them, then Copy the WorldPosition on that one, select the second Attachment and Paste the copied value into that one’s WorldPosition.

You should make sure the green line from the PrismaticConstraint is aligned with the direction you want the platform to move. If not rotate the Attachments until it does. If there are Arrows that are curved around the Attachments it means they aren’t rotated properly. If there is a red line between the Attachments then they aren’t aligned in the workspace properly
You can select the PrismaticConstraint to show the Properties. You can check the LimitsEnabled checkbox, but it probably won’t be necessary to use them in this situation.
Click the ActuatorType checkbox and select Servo which allows you to control the slide with a script.

Change the ServoMaxForce to about 100000. You may need to change it higher if your platform is heavy. Also change the Speed to 2 (it can be changed when you test it to find the speed you want the platform to move at.

If you move the platform to each end of the travel where you want it to be at you can see the values that the CurrentPosition are at when at the ends. Use these in your script to change the TargetPosition for the positions you want the platform to end up at.

Go to your Test tab up top, press the Play button, and check out your platform. It should be right where you left it. If it isn’t you need to recheck your Attachments for alignment. Select the Model tab and the Select tool and pick the PrismaticConstraint. Go to the TargetPosition value and change it to the value you got from the previous section where you moved the platform. It should move to that value. Now change it to the other value and it should move to the other end. If it doesn’t double-check that the platform isn’t Anchored, the ActuatorType is set to Servo, that your ServoMaxForce is set high enough to move the platform, and that the platform isn’t blocked by anything.

If you need help with scripting let me know and I can make a simple example. I just want you to give this a try with instructions first to see if you can figure it out. I’m not in Studio at the moment but I will be later on.

Here you go, there is an example of this in this game you can copy:

1 Like

Sorry it took a while. I’ve put a description of each line of the script in the button that moves the platform.
Here you go!

2 Likes