Hello everyone, I have a script that makes the player always face the mouse.
game.ReplicatedStorage.Play.Event:Connect(function()
local character = Player.Character or Player.CharacterAdded:Wait()
while character:FindFirstChild("Humanoid").Health > 0 do
game:GetService("RunService").Stepped:Wait()
character.UpperTorso.CFrame = CFrame.new(character.UpperTorso.Position, Vector3.new(mouse.Hit.p.X, character.UpperTorso.Position.Y, mouse.Hit.p.Z))
end
end)
However, I have a problem: Transparent parts, such as hitboxes can interfere with this causing inconsistencies. Someone told me to use Raycasts. I know I can blacklist certain objects, but i’m still not sure how to go about trying to use raycasts to make the player face the mouse. All help is appreciated
So what you’ll have to do is constantly making Rays that start at the A) Player’s Character B) Player’s Camera
and go to the mouse. You will have to blacklist the invisible parts from here. You will get the result of the raycast and position the character so that is faces the resulting position.