I made a decent gun that shoots and stuff, and has kind of ok camera recoil.
However, when I shoot, the camera recoil locks the camera in place, so I can't look around when im shooting.
GIF of shooting without moving camera:
https://gyazo.com/30362b45911b139bc733e2643742fc86
GIF of trying to move camera while shooting:
https://gyazo.com/2a787fdd9e9473ad255999f59d0f62eb
Local script function for recoil:
local function cameraRecoil(x,y,z)
local random = Random.new()
local camX,camY,camZ = random:NextNumber(-x/10,x/10),random:NextNumber(-y/10,y/10),random:NextNumber(-z/10,z/10)
local camera = workspace.CurrentCamera
local camTweenInfo = TweenInfo.new(0.1,Enum.EasingStyle.Bounce,Enum.EasingDirection.InOut,0,true,0)
local goal = {}
goal.CFrame = camera.CFrame * CFrame.Angles(camX,camY,camZ)
local recoilTween = TS:Create(camera,camTweenInfo,goal)
recoilTween:Play()
end
Where I call the recoil function:
local function fire(mouse,ignorePartList)
local lookPos = bulletSpread(mouse)
game.ReplicatedStorage.RemoteEvents.requestDraw:FireServer(weapon.bulletStartPoint.CFrame.Position,lookPos,Stats.Range.Value,Stats.muzzleVelocity.Value,ignorePartList)
gunModule:firePhysicalBullet(weapon.bulletStartPoint.CFrame.Position,lookPos,Stats.Range.Value,Stats.muzzleVelocity.Value,Stats.Damage.Value,bulletBase,ignorePartList)
gunRecoil(Stats.RecoilX.Value,Stats.RecoilY.Value)
cameraRecoil(Stats.cameraRecoilXYZ.Value.X,Stats.cameraRecoilXYZ.Value.Y,Stats.cameraRecoilXYZ.Value.Z)
local sound = game.ReplicatedStorage["Gun Shot"]:Clone()
sound.Parent = weapon.bulletStartPoint
local flash = game.ReplicatedStorage.muzzleFlash:Clone()
flash.Parent = weapon.bulletStartPoint
local light = Instance.new("PointLight",weapon.bulletStartPoint)
light.Brightness = 5
flash.Enabled = true
light.Enabled = true
sound:Play()
game:GetService("Debris"):AddItem(flash,0.1)
game:GetService("Debris"):AddItem(sound,2)
game:GetService("Debris"):AddItem(light,0.1)
end
Thx
EDIT: So I think I figured out why I can't move the camera. It's cuz I'm using tweens to move the camera, which I think kind of "locks" the camera control.
So now my question is, how do I move and tween it at the same time?
