Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do i make a part move that has players on it?

I tired to use a CFrame translation

for a = 0,10 do
	script.Parent.Part.CFrame = CFrame.new(Part.CFrame.x +.1, Part.CFrame.y, Part.CFrame.z)
	wait(0.001)
end

but the players did not stay on the part as it moved. so are there any other more effective methods to make the Part move with the players on it?

2 answers

✓ Accepted answer

A more efficient method would be to simply use a body position. This will physically move the part instead of teleporting it small amounts, moving players along with it.

Code formatting:

while true do
	BodyPosition.position = Vector3.new(x,y,z)
	wait(waittime)
	BodyPosition.position = Vector3.new(x,y,z)
end

Watch this video, it should help a lot.

2 comments

0

I found this very helpful in moving the part side to side but what about up and down?

0

If you watched the video, you noticed that they didn't enter in the specific coordinates, but used the position of two goal parts. Simply moving those goal parts (and possibly editing a few properties of the BP) to the correct position should work.

My first guess would be that you move the Character that is touching it with the block, with code that would look a little something like:

Part = script.Parent

Part.Touched:connect(function(hit)
	local Humanoid = hit.Parent:FindFirstChild("Humanoid")
	if (Humanoid) then
		hit.Parent:MoveTo(Part.CFrame.x + .1, hit.Parent.Torso.CFrame.y, hit.Parent.Torso.CFrame.z)
	end
end)

That should move the Character along with the block, but if not, try adding a bit of velocity to the Part.

This discussion is preserved as it was. New answers, comments, and votes are closed.