How to make a model fly via clickdetector

Very simple! I just want it so if you use a clickdetector, and you press it; it’ll put the camera to the vehicle, and you can control it, disabling the players controls so they can’t move; and if they press backspace it’ll stop controlling.

Just have no idea how to do this, any ideas how to achieve this effect?

1 Like

First thing that comes to mind is to make the players character into the vehicle and anchor their old character, then use ContextActionService to bind the action of returning to their own character

1 Like

Alright thanks! But how would you make the model fly? and to control the model?

Maybe moving the model towards the camera of the player when they’re trying to move (their Humanoid’s move direction is not (0,0,0) ) and either use a VectorForce to counteract gravity or anchor it and move it through setting the CFrame

I’ll try something, i’ll let you know the results, thanks!

My thought process went to creating a new camera instance instead of using the players current one. Similar to the guides on how to create a start screen.

In this case you would parent the new camera to the vehicle and offset its position which I would create a function to update the cameraPosition every time the vehicle moves.

-- Save the player's current camera
    local originalCamera = workspace.CurrentCamera

 local camera = Instance.new("Camera")
--Parent to vehicle
--camera.Position = vehiclePos + Offset

  -- Toggle the camera
--Add input logic here
    workspace.CurrentCamera = camera  -- Switch to the new camera

  -- Toggle the camera
--Add input logic here
    workspace.CurrentCamera = originalCamera -- Switch back when backspace pressed

Also here’s a simple toggle function to lock player controls:

local function lockPlayerMovement(player, lock)
	local character = player.Character
	local humanoid = character and character:FindFirstChildOfClass("Humanoid")
	
	if humanoid then
		if lock then
			humanoid.WalkSpeed = 0
			humanoid.JumpPower = 0
			movementLocked = true
		else
			humanoid.WalkSpeed = 16 -- Default WalkSpeed
			humanoid.JumpPower = 50 -- Default JumpPower
			movementLocked = false
		end
	end
end

Not sure on the flying aspect though. Hope this helps.