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

CFrame seat movement leaves player behind, what is wrong?

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

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.

2 comments

0

That is what i tried first time, but whenever the seat moved the player jumped off automatically. Isn't there any other way?

0

You could attach some sort of wheel with an attachment, and change the Torque depending on the user input

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