Plane Scripting Help

I want to make a very basic plane and I saw on devforum that I needed Vectorforce. I used it and it turned out ok. I’m wondering how to make the plane turn to my mouse position while also turning the vector force. how would I do this?

1 Like
1 Like

that post doesn’t really have anything besides looking into kits. I will try that

I think I got it but now I need to make the plane face the direction of my mouse. Does anyone know how to do this?

-- Roblox Services
local ContextActionService = game:GetService("ContextActionService")
local Players = game:GetService("Players")
 
-- Variables for the player, camera, and player’s mouse
local player = Players.LocalPlayer
local camera = workspace.CurrentCamera	
local mouse = player:GetMouse()

-- Function that is called when the player moves their mouse or finger
local function onAim()
	-- Make sure the character exists
	if player.Character then
		-- Finds the position of the mouse in the world and rotates the character model to face it
		local rootPart = player.Character:FindFirstChild("HumanoidRootPart")
		local mouseLocation = Vector3.new(mouse.Hit.X, mouse.Hit.Y, mouse.Hit.Z)
		rootPart.CFrame = CFrame.new(rootPart.Position, mouseLocation)
	end
end

ContextActionService:BindAction("Aim", onAim, false, Enum.UserInputType.MouseMovement)

This could probably help

3 Likes

I figured it out :slight_smile: Thanks for your help!x

1 Like