Hello there, I am making a gun system for my game but there is one problem with aiming. In third person I would like the camera look like if I am in shift lock only when I am aiming, how can I achieve this?
This is how my code looks like(client script)
mouse.Button1Down:Connect(function()
if aiming == true then
shooting = true
while shooting == true do
local mousePosition = mouseModule.GetPosition()
fireEvent:FireServer(mousePosition)
mouse.Button1Up:Connect(function()
shooting = false
end)
task.wait(0.2)
end
end
end)
tool.Unequipped:Connect(function()
shooting = false
aiming = false
camera.FieldOfView = 70
contextActionService:UnbindAction("Reload")
end)
tool.Equipped:Connect(function()
contextActionService:BindAction("Reload", function(name, state, obj)
if state == Enum.UserInputState.Begin then
reloadEvent:FireServer()
end
end, false, Enum.KeyCode.R)
end)
mouse.Button2Down:Connect(function()
if tool.Parent:IsA("Model") then
aiming = true
while aiming == true do
aiming = true
camera.FieldOfView = 50
mouse.Button2Up:Connect(function()
aiming = false
camera.FieldOfView = 70
end)
wait()
end
end
end)