Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
nich17 95
9 years ago

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

Log in to vote
1
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
9 years ago

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.

0
I found this very helpful in moving the part side to side but what about up and down? nich17 95 — 9y
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. Perci1 4988 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

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.

Answer this question