I am making a soccer game and I am trying to make it so when the player presses “G” their body will be facing the ball until G is released.
UserInputService.InputBegan:connect(function(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Guard then
ball = court:FindFirstChild("Ball")
local rootPart = player.Character:FindFirstChild("UpperTorso")
while true do
rootPart.CFrame = CFrame.lookAt(rootPart.Position, ball.Position)
wait()
end
end
end)
This is what I have so far and it technically works but the issue is every time the while loop runs it changes the direction the player is facing which makes it look very glitchy. Wondering if there was a way to make this a lot smoother.
I suggest you look into using a BodyGyro, or a AlignPosition joint. Body gyro would be my recommend, as they are easier to use, however they have been deprecated.
Good idea, but look vector is for getting the vector3 of what a part is “looking” at, specifically the vector3 position at the front face of the part, which is not really for this use case.