I want to make my character teleport 45* degrees of where the character is looking, assuming I'm in first person. I've tried to use rightvector and lookvector but I don't know how to get the 45-degree angle.
How to teleport character 45* degrees?
3 answers
So I assume you're confused how to get the proper direction. No cframe has a stock 45 degrees vector. You can easily get there with the lookvector of [that cframe offset by a 45deg cframe].
CFrame.Angles() returns a cframe with no position but rotated with the given radian angles. The radian angle you want is math.pi/-4. Y value spins vertically.
CFrame.Angles(0,math.pi/-4,0)Offset the original's rotation by 'multiplying' this. Then you have a useful direction:
(cf*CFrame.Angles(0,math.pi/-4,0)).lookVectorThen of course multiply it by a distance, add to the original. hope you get it!
local char = game.Players.LocalPlayer.Character
local ppartcf = char.PrimaryPart.CFrame
local new = ppartcf+(ppartcf*CFrame.Angles(0,math.pi/-4,0)).lookVector*5
char:SetPrimaryPartCFrame(new)
1 comment
That was exactly what I ment! Thank you so much bro! You are a god!!!
local plr = game.Players.LocalPlayer
repeat wait() until plr.Character
local char = plr.Character
char:SetPrimaryPartCFrame(char.PrimaryPart.CFrame * CFrame.Angles(math.rad(45),0,0))
1 comment
Didnt work. My character just bugs in place. I'm not trying to rotate my character. only make it dash in a direction. https://youtu.be/iW0eIaqiVdQ
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
"teleport 45* degrees of where the character is looking" makes no sense.
Yes it does. 0 or 360 degrees are forward. 90 is on your right. 180 is backwards and 170 is left. so 45 degrees would be somewhere in the middle between forward and right. What I am trying to do is that when you press down W and D you dont teleport forward or to the right, you teleport somewhere in between. Am I being mroe clear now?