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

CFrame seat movement leaves player behind, what is wrong?

Asked by 5 years ago

So I have this script that moves a model that contains a train model and a sea when W is pressed.Everything works fine except for the fact that the player is left behind when the train is moving.

seat = script.Parent
tram = script.Parent.Parent
plr = seat.Occupant

while true do
    if seat.Occupant ~= nil then
        print("sitting")
        seat.Occupant.Parent.isDriving.Value = true
        print (tram.forward.Value)
        while tram.forward.Value == true do
            --print(tram.tram.Position)
            --seat.Position = seat.Position + Vector3.new(0, 0, -1)
            --tram.Position = tram.Position + Vector3.new(0, 0, -1)
            tram:SetPrimaryPartCFrame(tram:GetPrimaryPartCFrame() * CFrame.new(0,0,-1))
            --seat.Occupant.Parent.HumanoidRootPart.Position = seat.Position
            wait()
        end

        while tram.backward.Value == true do
            wait()
        end
    end
    wait()  
end

What am I doing wrong?

1 answer

Log in to vote
0
Answered by 5 years ago

As far as I am aware, CFrames 'set' a part's location, whilst Vector3s 'move' its location. Try attaching the player to the seat, or using Vector3s and .position instead of CFrames.

0
That is what i tried first time, but whenever the seat moved the player jumped off automatically. Isn't there any other way? FriendlySniperZ 5 — 5y
0
You could attach some sort of wheel with an attachment, and change the Torque depending on the user input plasmascreen 143 — 5y
Ad

Answer this question