When the button I circled in this link is pressed, I want the gun to zoom in. How do I make this happen with the following script?
local Tool = script.Parent
a = false
cam = nil
wut = Tool.Parent
function onEquipped(mouse2)
mouse2.KeyDown:connect(onkeyDown)
mouse = mouse2
end
function onkeyDown(key)
if key == "z" then -- I don't want the zoom button to be z.
if not a then
cam = game.Workspace.CurrentCamera:clone()
cam.Parent = game.Workspace
game.Workspace.CurrentCamera.CameraSubject = Tool.Zoom
game.Workspace.CurrentCamera.CameraType = 1
Tool.Recoil.Value = 5
Tool.ZoomedIn.Value = true
Tool.Parent.Humanoid.WalkSpeed = 10
a = true
else
game.Workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character
game.Workspace.CurrentCamera:Remove()
game.Workspace.CurrentCamera = cam
Tool.ZoomedIn.Value = false
Tool.Recoil.Value = 10
Tool.Parent.Humanoid.WalkSpeed = 16
a = false
end
end
end
script.Parent.Equipped:connect(onEquipped)
