Hi all,
Recently I’ve been working on a tennis game with interesting game mechanics. Here I’m trying to make the player face where the player’s mouse is pointed at. At first it works really fine…until I started walking.
You can notice the weird choppy movement my character has once I start moving in a different direction from the one my mouse is pointed at. I wouldn’t really have a problem with that if it didn’t influence the direction of the tennis ball.
Here’s the code:
local Mouse = Player:GetMouse()
RunService.RenderStepped:Connect(function()
repeat wait() until game.Workspace:FindFirstChild("Ball")
local ball = game.Workspace.Ball
local character = Player.Character
local humanoid = character:WaitForChild("Humanoid")
if ball then
if humanoid.Health > 0 then
character.HumanoidRootPart.CFrame = CFrame.new(character.HumanoidRootPart.Position, Vector3.new(Mouse.Hit.p.X, character.HumanoidRootPart.Position.Y, Mouse.Hit.p.Z))
end
end
end)
How can I avoid the weird movement as shown above in the video?
Thanks in advance!