Part faces to Mouse Position too fast

  1. What do you want to achieve? Keep it simple and clear!
    I want to make working Turrets

  2. What is the issue? Include screenshots / videos if possible!
    When the Part looks at the mouse Positon, it goes to fast

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve tried looking for something but couldn’t find anything on the Dev Hub

Here is the Code (Local Script)


local mouse = game.Players.LocalPlayer:GetMouse()

game:GetService("RunService").RenderStepped:Connect(function()
	workspace.Part.CFrame = CFrame.lookAt(workspace.Part.Position,mouse.Hit.p)
	
end)

You can use tweening to slow it down.

local tweenService = game:GetService("TweenService")
local TWEEN_DURATION = .1 --//How long the tween takes to finish

local function pointToMouse()
local tweenInfo = TweenInfo.new(TWEEN_DURATION)
local goalCFrame = CFrame.lookAt(workspace.Part.Position, mouse.Hit.Position)

tweenService:Create(workspace.Part, tweenInfo, {CFrame = goalCFrame}):Play()
end

mouse.Move:Connect(pointToMouse)
1 Like