Hi guys!
Why is the script not working well?
I searched up on Google about it, but nothing useable information about it, what I’ve found.
And how can I make the aiming more smoother?
So here is a video + a picture and a script:
--Aim script
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local held = false
mouse.Button2Down:connect(function(ZoomIn)
held = true
game.Workspace.Camera.FieldOfView = game.Workspace.Camera.FieldOfView - 15.6
game.Players.LocalPlayer.Character:WaitForChild("Humanoid").WalkSpeed = game.Players.LocalPlayer.Character:WaitForChild("Humanoid").WalkSpeed - 1
script.Parent.Camera.Disabled = false
end)
mouse.Button2Up:connect(function(ZoomOut)
held = false
game.Workspace.Camera.FieldOfView = game.Workspace.Camera.FieldOfView + 15.6
game.Players.LocalPlayer.Character:WaitForChild("Humanoid").WalkSpeed = game.Players.LocalPlayer.Character:WaitForChild("Humanoid").WalkSpeed + 1
script.Parent.Camera.Disabled = true
end)
spawn(function(ZoomIn)
while true do
wait(.5)
end
end)
--Created by: ImFarley
--//THIRD PERSON SHOOTER CAMERA SCRIPT\\--
local uis = game:GetService("UserInputService")
local ts = game:GetService("TweenService")
local cam = workspace.CurrentCamera
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
repeat wait() until plr.Character and plr.Character.Parent == workspace
local char = plr.Character
local hum = char:WaitForChild("Humanoid")
local waist = char.UpperTorso:WaitForChild("Waist")
local root = char:WaitForChild("HumanoidRootPart")
hum.CameraOffset = Vector3.new(3, 0, 0)
hum.AutoRotate = false
cam.CameraSubject = hum
game:GetService("RunService").RenderStepped:Connect(function()
uis.MouseBehavior = Enum.MouseBehavior.LockCenter
local delta = uis:GetMouseDelta()
local deltaX, deltaY = delta.X, -delta.Y
cam.CFrame = CFrame.new(cam.CFrame.p, cam.CFrame* CFrame.new(deltaX, deltaY, -2000).p)
local offset = char.LowerTorso.CFrame:ToWorldSpace(CFrame.new(0, char.UpperTorso.Size.Y/2, 0)) * CFrame.fromEulerAnglesXYZ(math.max(math.min(math.asin((mouse.Hit.p - mouse.Origin.p).unit.y), .6), -.75), 0, 0) * CFrame.new(0, char.UpperTorso.Size.Y/2, 0)
waist.C1 = offset:inverse() * char.LowerTorso.CFrame * CFrame.new(0, .8, 0)
local tweenInfo = TweenInfo.new(.15, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0)
local newRootCF = CFrame.new(root.CFrame.p,root.CFrame.p+Vector3.new(cam.CFrame.lookVector.X,0,cam.CFrame.lookVector.Z))
local tween = ts:Create(root, tweenInfo, {["CFrame"] = newRootCF}, true)
tween:Play()
end)