Hi guys!
How can I make, if the player holding a gun, and he want to aim with this gun.
And to aim: the player need to Hold MB2 or just click once to enter “aiming mode”
And I have a Third Person Camera. [NOT MADE BY ME]
Here is the script with a picture:
--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)
And how can I make it if the player holding or just clicked once MB2 the script:
camerascript.disabled = false
Here is a picture if the script enabled:
And you see the mouse is in the middle of the screen, how can I make to invisible when I’m enabled the
script (or the “AIMING MODE”). If the mouse invisible then a “aiming cross” will visible. If the player not holding or just clicked once MB2 then the script will disabled, and the “aiming cross” invisible.
Sorry if it’s not understeadable. I’am from Hungary, and I don’t really speak English languange.