Solved. Thank you Sekonds for helping
1 Like
If the player won’t rotate weirdly like lay on it’s belly or back you could get the Y component of the Humanoid Root Part’s orientation and tell if it’s facing x or y by calculating if Y is between 0 and 90 for example. Here is my script:
local rootPart = character:WaitForChild('HumanoidRootPart')
while wait() do
local Direction
local yRot = rootPart.Orientation.Y
if (yRot >= 0 and yRot <= 90) or (yRot <= -90 and yRot >= -180) then
Direction = 'X'
elseif (yRot <= 0 and yRot >= -90) or (yRot >= 90 and yRot <= 180) then
Direction = 'Y'
end
print(Direction)
end
I think this should fix the problem:
local spreadVal = 3 - math.random(0, 6) --idk if you can do (-3, 3) but this works
local spreadVector = enemyTorso.CFrame.rightVector * spreadVal
Newpart.Position = RaycastResult.Position + spreadVector
You’ll need to make a new variable for the enemy torso. If you’re not casting it from the enemy torso but the gun instead, cast it from a part on the gun - anything on the same axis of rotation as the torso will work.
2 Likes
Thank you so much
Life saver
2 Likes
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.