I am trying to make my character Humanoidrootpart CFrame face the mouse position but the character just tweens to the spawn. I’ve been stuck trying to make a third person aim system for so long.
This is what I tried:
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local tweenService = game:GetService("TweenService")
local tweenInformation = TweenInfo.new(0.15,Enum.EasingStyle.Quart,Enum.EasingDirection.In,0,false,0)
local tool = script.Parent
local character = player.Character or player.CharacterAdded:Wait()
local UserGameSettings = UserSettings():GetService("UserGameSettings")
local canaim = false
local stillaim = false
local root = character.HumanoidRootPart
local hitpos = mouse.Hit.p
local aim = {CFrame = CFrame.new(root.Position) * CFrame.Angles(0,Vector3.new(CFrame.new(root.Position, hitpos):ToOrientation()).Y,0)}
local aimInfo = tweenService:Create(root,tweenInformation,aim)
local function startaim ()
if canaim == true then
aimInfo:Play()
end
end
tool.Equipped:Connect(function()
canaim = true
mouse.Button2Up:Connect(function()
mb2 = false
aimanim:Stop()
if mb1 == false then
stillaim = false
end
end)
mouse.Button1Down:Connect(function()
mb1 = true
wait(0.1)
UserGameSettings.RotationType = Enum.RotationType.CameraRelative
end)
mouse.Button1Up:Connect(function()
mb1 = false
if mb2 == false then
stillaim = false
UserGameSettings.RotationType = Enum.RotationType.MovementRelative
end
end)
mouse.Button2Down:Connect(function()
stillaim = true
mb2 = true
wait(0.1)
if canaim == true then
aimanim:Play()
startaim()
end
end)
end)