Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to rotate but not position using cframe?

So this code rotates the player to where the mouse clicked, it works perfectly but when I click while moving it moves the player back a bit and I want that to stop. So what I'm asking is how to remove the positioning and only rotate (or a counter to the moving back)

player.Character.HumanoidRootPart.CFrame = CFrame.new(player.Character.HumanoidRootPart.Position, mousehitpos) -- mousehitpos is mouse.Hit.p

2 comments

0

You could try to use CFrame.lookAt() to turn your character to face your mouse without moving you backwards

0

^ You'll want to replace the Y axis with your HumanoidRootPart's, though

1 answer

Hi you should use CFrame.Angles and math.rad.

read about rotationg objects using CFrame.Angles here:

https://developer.roblox.com/en-us/articles/Understanding-CFrame

an example code for using CFrame.Angles is:

local part = game.workspace.Part

targetframe = CFrame.Angles(0, math.rad(10),0)

part.CFrame = tragetframe

Notice how i used math.rad instead of just inserting an angle. This is because CFrame numbers dont work in the way you would expect (for some reason) so you could use math.rad if you want to refer to actual angles!

Hope this wasn't too confusing!

Any questions? Just ask!

2 comments

0

Radians are the SI unit for measuring angles. 'math.rad' simply converts degrees into radian form

0

how would I do this but using a position

This discussion is preserved as it was. New answers, comments, and votes are closed.