I am making a 17th Century game and I am currently trying to make the R6 character follow the mouse, this code works but is fast. How would I make it slower?
Players = game:GetService('Players')
Player = Players.LocalPlayer
Mouse = Player:GetMouse()
Char = Player.Character
if not Char then
Player.CharacterAdded:Wait()
Char = Player.Character
end
RootPart = Char:WaitForChild('HumanoidRootPart')
RunService.Stepped:connect(function()
local MousePos = Mouse.Hit.p
local lookVector = Vector3.new(MousePos.X,RootPart.CFrame.Y,MousePos.Z)
RootPart.CFrame = CFrame.new(RootPart.CFrame.p,lookVector)
end)
It sadly did not work, It got a bit glitchy. : (
Yes I misinterpreted the question, hence I deleted my solution
What do you mean by “fast”? Could you include a video or gif?
Alright please give me a minute to get it.
If you want it to smoothly turn slower then you can look into tweening, but I dont think creating a new tween every frame is a good idea.
Alright, thankyou for helping.
just lerp the cframe lol
Players = game:GetService('Players')
Player = Players.LocalPlayer
Mouse = Player:GetMouse()
Char = Player.Character
if not Char then
Player.CharacterAdded:Wait()
Char = Player.Character
end
RootPart = Char:WaitForChild('HumanoidRootPart')
local rs = game:GetService("RunService")
local speed = 8 -- change on how fast you want it to be
rs.Heartbeat:Connect(function(bruh)
local MousePos = Mouse.Hit.p
local lookVector = Vector3.new(MousePos.X,RootPart.CFrame.Y,MousePos.Z)
RootPart.CFrame = RootPart.CFrame:Lerp(CFrame.new(RootPart.CFrame.p,lookVector),bruh * speed)
end)
1 Like
Thankyou very much, this has helped me a lot.