You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? I want to make my recoil function not spin me 180 degrees when I shoot in first person.
-
What is the issue? The issue is that my camera gets spun 180 degrees every single time I shoot.
-
What solutions have you tried so far? Looked on Developer Forum, could not find anything.
I am firing the function when activating the tool, the problem is with the function however I don’t know how to fix it, help is appreciated
Here is my code:
local Recoil_Min = 1;
local Recoil_Max = 1.5;
local Spread_Recoil_Min = -0.9;
local Spread_Recoil_Max = 0.1;
function Recoil()
local RecoilPart = Instance.new('Part', workspace);
RecoilPart.Anchored = true;
RecoilPart.Position = PlayerMouse.Hit.Position;
RecoilPart.CanCollide = false;
RecoilPart.Transparency = 0.5;
RecoilPart.Color = Color3.fromRGB(255, 0, 0);
RecoilPart.Size = Vector3.new(1, 1, 1);
local CalculatedRecoil = math.random(Recoil_Min, Recoil_Max);
local CalculatedSpreadRecoil = math.random(Spread_Recoil_Min, Spread_Recoil_Max);
local Offset = Vector3.new(0, 0, 0);
RecoilPart.CFrame = game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame * CFrame.new(Offset);
local Camera = game.Workspace.CurrentCamera;
Camera.CFrame = CFrame.lookAt(Camera.CFrame.Position, RecoilPart.CFrame.Position + Vector3.new(0, CalculatedRecoil, 0));
end;