The issue I’m facing is trying to create 4 direcitonal combat system, meaning your swing direciton is dependant on where your camera is orientated, I tried multiple things like:
local StartingDirection = "Down"
local Beats = 0
local tempx,tempy,tempz = Camera.CFrame:ToOrientation()
local prevX = tempx
local prevY = tempy
RunService.RenderStepped:Connect(function()
local X,Y,Z = Camera.CFrame:ToOrientation()
if prevX ~= X and math.abs(prevX-X) >= .02 then
local currentDirection
if prevX < X then
currentDirection = "Down"
elseif prevX > X then
currentDirection = "Up"
end
if currentDirection ~= StartingDirection then
if Beats then Beats += 1 else Beats = 1 end
if Beats > 2 then
Beats = 0
print(StartingDirection)
StartingDirection = currentDirection
end
end
end
if prevY ~= Y and math.abs(prevY-Y) >= .02 then
local currentDirection
if prevY < Y then
currentDirection = "Left"
elseif prevY > Y then
currentDirection = "Right"
end
if currentDirection ~= StartingDirection then
if Beats then Beats += 1 else Beats = 1 end
if Beats > 2 then
Beats = 0
print(StartingDirection)
StartingDirection = currentDirection
end
end
end
prevX = X
end)
but if you start spinning around it triggers up and down, when it should be if you spin right it shouldn’t change direction, also if you start sliding your camera up it starts bugging like crazy.
External Media