so theres a really good fps arm scripts that is called “EasyFirstPerson” but the issue is they use my avatar model instead of the game character
heres the script
local GeneralSettings = {
CanSwing = true;
CanBobble = true;
CanAim = true;
CanRecoil = true;
RecoilYRotMax = 16;
RecoilZPosMax = 1;
RecoilYPosMax = 0.5;
HeadOffset = 0;
ArmsVisible = true;
ArmTransparency = 0;
CameraAnimation = false; -- Must have "FakeCamera" and its joint with same name in order to enable this
CustomGripNames = {
["ToolGrip"] = true,
}
}
local RunService = game:GetService("RunService")
local PhysicsService = game:GetService("PhysicsService")
local TweenService = game:GetService("TweenService")
local UserInputService = game:GetService("UserInputService")
local Workspace = game:GetService("Workspace")
local ReplicatedFirst = game:GetService("ReplicatedFirst")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Camera = Workspace.CurrentCamera
if Camera:FindFirstChild("Viewmodel") then
Camera:FindFirstChild("Viewmodel"):Destroy()
end
if Camera:FindFirstChild("ViewmodelBox") then
Camera:FindFirstChild("ViewmodelBox"):Destroy()
end
local Miscs = ReplicatedStorage:WaitForChild("Miscs")
local Modules = ReplicatedStorage:WaitForChild("Modules")
local ViewmodelRigs = Miscs.ViewmodelRigs
local Utilities = require(Modules.Utilities)
local Math = Utilities.Math
local Spring = Utilities.Spring
local Character
repeat Character = Player.Character wait() until Character
local Head = Character:WaitForChild("Head")
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
local Humanoid = Character:WaitForChild("Humanoid")
local OffStates = {"Jumping", "PlatformStanding", "Ragdoll", "Seated", "FallingDown", "FreeFalling", "GettingUp", "Swimming", "Climbing"}
local OnStates = {"Running"}
local ArmParts = {}
local RigType = nil
local HasAimPoints = false
local IsAiming = false
local ShowViewmodel = false
local CurrentArmTransparency = GeneralSettings.ArmTransparency
local OriginalAimSpeed = 15
local speed = 0
local distance = 0
local velocity = Vector3.new()
local c1 = 0
local c2 = 0
local c3 = 0
local c4 = 0
local c5 = 0
local c6 = 0
local c7 = CFrame.new()
--Legends:
--[s]: Speed
--[d]: Damper
--[t]: Target
--[p]: Position
--[v]: Velocity
local SpeedSpring = Spring.spring.new()
SpeedSpring.s = 16
local SwaySpring = Spring.spring.new(0)
SwaySpring.s = 8
SwaySpring.d = 1
local SwaySpeed = Spring.spring.new(0)
SwaySpeed.s = 1
SwaySpeed.d = 1
SwaySpeed.t = 1
local VelocitySpring = Spring.spring.new(Vector3.new())
VelocitySpring.s = 16
VelocitySpring.t = Vector3.new()
VelocitySpring.p = Vector3.new()
local AimSpring = Spring.spring.new()
AimSpring.s = OriginalAimSpeed
AimSpring.d = 0.9
AimSpring.t = 0
local SwingSpring = Spring.spring.new(Vector3.new())
SwingSpring.s = 13
SwingSpring.d = 0.4
--R15
local LowerTorso
local UpperTorso
local Root
local Waist
local VMLowerTorso
local VMUpperTorso
local VMRoot
local VMWaist
local LeftUpperArm
local LeftLowerArm
local LeftHand
local RightUpperArm
local RightLowerArm
local RightHand
local LeftElbow
local LeftWrist
local RightElbow
local RightWrist
local VMLeftUpperArm
local VMLeftLowerArm
local VMLeftHand
local VMRightUpperArm
local VMRightLowerArm
local VMRightHand
local VMLeftElbow
local VMLeftWrist
local VMRightElbow
local VMRightWrist
--R6
--local ShirtTexture
local Torso
local RootHip
local VMTorso
local VMRootHip
local LeftArm
local RightArm
local VMLeftArm
local VMRightArm
--General
local VMHumanoid
local VMHead
local VMHumanoidRootPart
local LeftShoulder
local RightShoulder
local VMLeftShoulder
local VMRightShoulder
local FakeCamera
local FakeCameraJoint
local OldCamCF
local CustomGrip
local LeftGrip
local RightGrip
local LastPart0C
local LastPart0L
local LastPart0R
local CurrentTool
local Setting
local Offset
local DescendantAddedConnection
local AimPointTable = {}
local CurrentAimPoint
local Viewmodel = ViewmodelRigs[Humanoid.RigType.Name]:Clone()
Viewmodel.Name = "Viewmodel"
local ViewmodelBox = Miscs.ViewmodelBox:Clone()
ViewmodelBox.Parent = Camera
VMHumanoid = Viewmodel:WaitForChild("Humanoid")
VMHumanoid:SetStateEnabled(Enum.HumanoidStateType.Climbing, false)
VMHumanoid:SetStateEnabled(Enum.HumanoidStateType.Dead, false)
VMHumanoid:SetStateEnabled(Enum.HumanoidStateType.FallingDown, false)
VMHumanoid:SetStateEnabled(Enum.HumanoidStateType.Flying, false)
VMHumanoid:SetStateEnabled(Enum.HumanoidStateType.Freefall, false)
VMHumanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, false)
VMHumanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
VMHumanoid:SetStateEnabled(Enum.HumanoidStateType.Landed, false)
VMHumanoid:SetStateEnabled(Enum.HumanoidStateType.Physics, false)
VMHumanoid:SetStateEnabled(Enum.HumanoidStateType.PlatformStanding, false)
VMHumanoid:SetStateEnabled(Enum.HumanoidStateType.Ragdoll, false)
VMHumanoid:SetStateEnabled(Enum.HumanoidStateType.Running, false)
VMHumanoid:SetStateEnabled(Enum.HumanoidStateType.RunningNoPhysics, false)
VMHumanoid:SetStateEnabled(Enum.HumanoidStateType.Seated, false)
VMHumanoid:SetStateEnabled(Enum.HumanoidStateType.Swimming, false)
VMHumanoid:SetStateEnabled(Enum.HumanoidStateType.StrafingNoPhysics, false)
Viewmodel.PrimaryPart.CFrame = CFrame.new(0, 10e5, 0)
Viewmodel.Parent = Camera
ViewmodelBox.MainHolder.C0 = CFrame.new(0,0,-0.5)
local successful, errorMessage = pcall(function()
VMHumanoid:ApplyDescription(Players:GetHumanoidDescriptionFromUserId(Player.UserId))
end)
for _, Part in pairs(Viewmodel:GetDescendants()) do
if Part:IsA("BasePart") then
PhysicsService:SetPartCollisionGroup(Part, "Viewmodel")
local LowerName = Part.Name:lower()
if LowerName:match("arm") or LowerName:match("hand") then
table.insert(ArmParts, Part)
end
elseif Part:IsA("Decal") then
Part:Destroy()
elseif Part:IsA("Accessory") then
Part:Destroy()
elseif Part:IsA("BaseScript") then
Part:Destroy()
elseif Part:IsA("ForceField") then
Part:Destroy()
end
end
VMHead = Viewmodel:WaitForChild("Head")
VMHumanoidRootPart = Viewmodel:WaitForChild("HumanoidRootPart")
if Humanoid.RigType == Enum.HumanoidRigType.R15 then
RigType = "R15"
-- setup variables
LowerTorso = Character:WaitForChild("LowerTorso")
UpperTorso = Character:WaitForChild("UpperTorso")
Root = LowerTorso:WaitForChild("Root")
Waist = UpperTorso:WaitForChild("Waist")
LeftUpperArm = Character:WaitForChild("LeftUpperArm")
LeftLowerArm = Character:WaitForChild("LeftLowerArm")
LeftHand = Character:WaitForChild("LeftHand")
RightUpperArm = Character:WaitForChild("RightUpperArm")
RightLowerArm = Character:WaitForChild("RightLowerArm")
RightHand = Character:WaitForChild("RightHand")
LeftShoulder = LeftUpperArm:WaitForChild("LeftShoulder")
RightShoulder = RightUpperArm:WaitForChild("RightShoulder")
LeftElbow = LeftLowerArm:WaitForChild("LeftElbow")
LeftWrist = LeftHand:WaitForChild("LeftWrist")
RightElbow = RightLowerArm:WaitForChild("RightElbow")
RightWrist = RightHand:WaitForChild("RightWrist")
--
VMLowerTorso = Viewmodel:WaitForChild("LowerTorso")
VMUpperTorso = Viewmodel:WaitForChild("UpperTorso")
VMRoot = VMLowerTorso:WaitForChild("Root")
VMWaist = VMUpperTorso:WaitForChild("Waist")
VMLeftUpperArm = Viewmodel:WaitForChild("LeftUpperArm")
VMLeftLowerArm = Viewmodel:WaitForChild("LeftLowerArm")
VMLeftHand = Viewmodel:WaitForChild("LeftHand")
VMRightUpperArm = Viewmodel:WaitForChild("RightUpperArm")
VMRightLowerArm = Viewmodel:WaitForChild("RightLowerArm")
VMRightHand = Viewmodel:WaitForChild("RightHand")
VMLeftShoulder = VMLeftUpperArm:WaitForChild("LeftShoulder")
VMRightShoulder = VMRightUpperArm:WaitForChild("RightShoulder")
VMLeftElbow = VMLeftLowerArm:WaitForChild("LeftElbow")
VMLeftWrist = VMLeftHand:WaitForChild("LeftWrist")
VMRightElbow = VMRightLowerArm:WaitForChild("RightElbow")
VMRightWrist = VMRightHand:WaitForChild("RightWrist")
else
RigType = "R6"
-- setup variables
Torso = Character:WaitForChild("Torso")
LeftArm = Character:WaitForChild("Left Arm")
RightArm = Character:WaitForChild("Right Arm")
RootHip = HumanoidRootPart:FindFirstChild("Root Hip") or HumanoidRootPart:FindFirstChild("RootJoint")
LeftShoulder = Torso:WaitForChild("Left Shoulder")
RightShoulder = Torso:WaitForChild("Right Shoulder")
--
VMTorso = Viewmodel:WaitForChild("Torso")
VMLeftArm = Viewmodel:WaitForChild("Left Arm")
VMRightArm = Viewmodel:WaitForChild("Right Arm")
VMRootHip = VMHumanoidRootPart:FindFirstChild("Root Hip") or VMHumanoidRootPart:FindFirstChild("RootJoint")
VMLeftShoulder = VMTorso:WaitForChild("Left Shoulder")
VMRightShoulder = VMTorso:WaitForChild("Right Shoulder")
end
if GeneralSettings.CameraAnimation then
FakeCamera = Character:WaitForChild("FakeCamera")
FakeCameraJoint = HumanoidRootPart:WaitForChild("FakeCamera")
end
local MainHolder = ViewmodelBox.MainHolder
MainHolder.Part0 = ViewmodelBox
MainHolder.Part1 = VMHumanoidRootPart
--print("Viewmodel initalized")
local function ViewmodelBob(a, r, basewalkspeed)
local a, r = a or 1, r or 1
local d, s, v = distance * 6.28318 * 3 / 4, speed, -velocity
--if s < basewalkspeed then
local w = Vector3.new(r * math.sin(d / 4 - 1) / 256 + r * (math.sin(d / 64) - r * v.z / 4) / 256, r * math.cos(d / 128) / 128 - r * math.cos(d / 8) / 256, r * math.sin(d / 8) / 128 + r * v.x / 1024) * s / 20 * 6.28318
return CFrame.new(r * math.cos(d / 8 - 1) * s / 196, 1.25 * a * math.sin(d / 4) * s / 512, 0) * Math.FromAxisAngle(w)
--else
--local w = Vector3.new((r * math.sin(d / 4 - 1) / 256 + r * (math.sin(d / 64) - r * v.z / 4) / 512) * s / 20 * 6.28318, (r * math.cos(d / 128) / 128 - r * math.cos(d / 8) / 256) * s / 20 * 6.28318, r * math.sin(d / 8) / 128 * (5 * s - 56) / 20 * 6.28318 + r * v.x / 1024)
--return CFrame.new(r * math.cos(d / 8 - 1) * (5 * s - 56) / 196, 1.25 * a * math.sin(d / 4) * s / 512, 0) * Math.FromAxisAngle(w)
--end
end
local function ViewmodelSway(a)
local d, s = os.clock() * 6, 2 * (1.2 - a)
return CFrame.new(math.cos(d / 8) * s / 128, -math.sin(d / 4) * s / 128, math.sin(d / 16) * s / 64)
end
local function CheckIfAlive()
return (Character and Character.Parent and Humanoid and Humanoid.Parent and Humanoid:GetState() ~= Enum.HumanoidStateType.Dead)
end
local function IsFirstPerson()
return (Camera.Focus.p - Camera.CoordinateFrame.p).Magnitude <= 1
end
local function GetTool()
return Character:FindFirstChildOfClass("Tool")
end
local function VisibleArms(bool)
if GeneralSettings.ArmsVisible then
local castshadow = not bool
for i, part in ipairs(ArmParts) do
part.LocalTransparencyModifier = CurrentArmTransparency
part.CastShadow = castshadow
end
end
end
local function SetViewmodelVisible(bool, hasScopeEnabled)
CurrentArmTransparency = hasScopeEnabled and 1 or (bool == false and 0 or GeneralSettings.ArmTransparency)
VisibleArms(bool)
end
local function OnChildAdded(Obj)
--task.wait()
--spawn(function()
if Obj:IsA("Tool") then
wait()
CurrentTool = Obj
if Obj:FindFirstChild("Setting") then
Setting = require(Obj.Setting)
AimSpring.s = Setting.ViewmodelAimSpeed or OriginalAimSpeed
end
if Obj:FindFirstChild("AimPoints") then
if #Obj.AimPoints:GetChildren() > 0 then
for i, v in ipairs(Obj.AimPoints:GetChildren()) do
table.insert(AimPointTable, {
Id = i,
AimPoint = v
})
end
CurrentAimPoint = AimPointTable[1].AimPoint
Offset = nil
HasAimPoints = true
end
end
for _, instance in pairs(Obj:GetDescendants()) do
if instance:IsA("BasePart") then
PhysicsService:SetPartCollisionGroup(instance, "Viewmodel")
end
end
local function DAdded(descendant)
if descendant:IsA("Motor6D") or descendant:IsA("Weld") then
--wait()
if Setting and Setting.CustomGripEnabled then
if descendant.Name == Setting.CustomGripName then
local Handle = Obj:FindFirstChild("Handle")
if Handle then
local RightGrip = Character:FindFirstChild("RightGrip", true)
if RightGrip then
RightGrip.Enabled = false
CustomGrip = descendant
LastPart0C = CustomGrip.Part0
else
CustomGrip = descendant
LastPart0C = CustomGrip.Part0
end
else
CustomGrip = descendant
LastPart0C = CustomGrip.Part0
end
end
else
if GeneralSettings.CustomGripNames[Obj.Name] then
CustomGrip = descendant
LastPart0C = CustomGrip.Part0
elseif descendant.Name == "LeftGrip" then
LeftGrip = descendant
LastPart0L = LeftGrip.Part0
elseif descendant.Name == "RightGrip" then
RightGrip = descendant
LastPart0R = RightGrip.Part0
end
end
end
end
for _, instance in pairs(Character:GetDescendants()) do
DAdded(instance)
end
DescendantAddedConnection = Character.DescendantAdded:Connect(DAdded)
end
--end)
end
local function OnChildRemoved(Obj)
--task.wait()
--spawn(function()
if Obj:IsA("Tool") then
--wait()
--[[CustomGrip = nil
LastPart0C = nil
LeftGrip = nil
LastPart0L = nil
RightGrip = nil
LastPart0R = nil]]
CurrentTool = nil
Setting = nil
CurrentAimPoint = nil
Offset = nil
if DescendantAddedConnection then
DescendantAddedConnection:Disconnect()
DescendantAddedConnection = nil
end
HasAimPoints = false
table.clear(AimPointTable)
AimSpring.s = OriginalAimSpeed
end
--end)
end
local function Disable()
RunService:UnbindFromRenderStep("UpdateViewmodel")
Viewmodel:Destroy()
ViewmodelBox:Destroy()
end
-- update character's off states
for _, state in pairs(OffStates) do
Humanoid[state]:Connect(function()
Active = false
end)
end
-- update character's on states
for _, state in pairs(OnStates) do
Humanoid[state]:Connect(function(speed)
Active = (speed > 1)
end)
end
function _G.SetAimEnabled(Value, Id)
IsAiming = Value
if HasAimPoints then
CurrentAimPoint = AimPointTable[Id].AimPoint
end
end
function _G.RecoilViewmodel(Value)
c1 = Value
end
function _G.SetViewmodelTransparent(Enabled)
local LocalTransparency = Enabled and 1
if CurrentTool then
for _, child in pairs(CurrentTool:GetDescendants()) do
if child:IsA("Beam") or child:IsA("Trail") or child:IsA("ParticleEmitter") then
if not child.Name == "SmokeTrail" then
child.Enabled = not Enabled
end
end
if child:IsA("RodConstraint") or child:IsA("RopeConstraint") or child:IsA("SpringConstraint") then
child.Visible = not Enabled
end
if child:IsA("BasePart") or child:IsA("Texture") or child:IsA("Decal") then
child.LocalTransparencyModifier = 1
end
end
end
SetViewmodelVisible(ShowViewmodel, Enabled)
end
for i, v in pairs(Character:GetChildren()) do
OnChildAdded(v)
end
Character.ChildAdded:Connect(OnChildAdded)
Character.ChildRemoved:Connect(OnChildRemoved)
RunService:BindToRenderStep("UpdateViewmodel", Enum.RenderPriority.Camera.Value + 1, function(dt)
--local Tool = GetTool()
local MouseDelta = UserInputService:GetMouseDelta()
c1 = c1 > 0.1 and Math.Lerp(c1, 0, dt * 11) or 0
local a = VelocitySpring.v
SwingSpring.t = Vector3.new(a.z / 1024 / 32 + a.y / 1024 / 16 + (MouseDelta.y / 10) / 1024 * 3 / 2, a.x / 1024 / 32 + (MouseDelta.x / 10) / 1024 * 3 / 2, -(MouseDelta.x / 10) / 1024 * 3 / 2)
local Aim = AimSpring.p
local RelativeVector = CFrame.new().VectorToObjectSpace(HumanoidRootPart.CFrame, HumanoidRootPart.Velocity)
SpeedSpring.t = (Active and Humanoid.Health > 0) and (Vector3.new(1, 0, 1) * RelativeVector).magnitude or 0
VelocitySpring.t = RelativeVector
speed = SpeedSpring.p
distance = distance + dt * SpeedSpring.p
velocity = VelocitySpring.p
if CheckIfAlive() and IsFirstPerson() then
if GeneralSettings.CameraAnimation then
local NewCamCF = FakeCameraJoint.Transform
if OldCamCF then
--Camera.CFrame = Camera.CFrame * NewCamCF:ToObjectSpace(NewCamCF)
local _, _, Z = NewCamCF:ToOrientation()
local X, Y, _ = NewCamCF:ToObjectSpace(OldCamCF):ToEulerAnglesXYZ()
Camera.CFrame = Camera.CFrame * CFrame.Angles(X, Y, -Z)
end
OldCamCF = NewCamCF
--else
--Camera.CFrame = Camera.CFrame
end
c2 = Math.Lerp(c2, GeneralSettings.RecoilYRotMax * c1, c1 == 0 and dt * 7 or dt * 6) + Math.Lerp(c3, Math.Randomize(2) * c1, c1 == 0 and dt * 7 or dt / 2)
c3 = Math.Lerp(c3, Math.Randomize(1.3) * c1, c1 == 0 and dt * 7 or dt * 3)
c4 = Math.Lerp(c4, Math.Randomize(5) * c1, c1 == 0 and dt * 7 or dt / 3)
c5 = Math.Lerp(c5, GeneralSettings.RecoilYPosMax * c1, c1 == 0 and dt * 7 or dt * 0.4)
c6 = Math.Lerp(c6, GeneralSettings.RecoilZPosMax * c1, c1 == 0 and dt * 7 or dt * 0.9)
c7 = CFrame.new(0, c5, c6) * CFrame.Angles(math.rad(c2), c3, c4)
local AimOffset = CFrame.new() * CFrame.new(0, -1.5, 0)
local AimCFrame = CFrame.new()
local CF = CFrame.new()
CF = Camera.CoordinateFrame * CFrame.new(0, 0, (Camera.FieldOfView / 90 - 1) * 0.3)
if GeneralSettings.CanSwing then
CF = CF * Math.FromAxisAngle(SwingSpring.v)
end
if GeneralSettings.CanBobble then
CF = CF * ViewmodelBob(0.7 - 0.3 * AimSpring.p, 1 - 0.8 * AimSpring.p, Humanoid.WalkSpeed) * ViewmodelSway(Aim)
end
if GeneralSettings.CanAim then
if IsAiming then
MouseDelta = MouseDelta * 0.75
AimSpring.t = 1
else
AimSpring.t = 0
end
if CurrentTool then --if Tool then
if CurrentAimPoint then
Offset = (Offset or CFrame.new()):Lerp(ViewmodelBox.CFrame:ToObjectSpace(CurrentAimPoint.CFrame * AimOffset):Inverse(), 0.35)
AimCFrame = AimCFrame * AimCFrame:Lerp(Offset, AimSpring.p)
end
end
end
if GeneralSettings.CanRecoil then
CF = CF * c7
end
local CamOffset = -Humanoid.CameraOffset
ViewmodelBox.CFrame = (CF * AimCFrame * CFrame.new(CamOffset.X * 0.5, CamOffset.Y * 0.5, CamOffset.Z * 0.5)) + (Camera.CoordinateFrame.UpVector * (-1.5 - GeneralSettings.HeadOffset))
if CustomGrip and LastPart0C then
CustomGrip.Part0 = Viewmodel:FindFirstChild(LastPart0C.Name, true)
end
if LeftGrip and LastPart0L then
--[[if RigType == "R15" then
LeftGrip.Part0 = VMLeftHand
elseif RigType == "R6" then
LeftGrip.Part0 = VMLeftArm
end]]
LeftGrip.Part0 = Viewmodel:FindFirstChild(LastPart0L.Name, true)
end
if RightGrip and LastPart0R then
--[[if RigType == "R15" then
RightGrip.Part0 = VMRightHand
elseif RigType == "R6" then
RightGrip.Part0 = VMRightArm
end]]
RightGrip.Part0 = Viewmodel:FindFirstChild(LastPart0R.Name, true)
end
if not ShowViewmodel then
ShowViewmodel = true
SetViewmodelVisible(ShowViewmodel)
end
else
ViewmodelBox.CFrame = CFrame.new(0, 10e5, 0)
if CustomGrip and LastPart0C then
CustomGrip.Part0 = LastPart0C
end
if LeftGrip and LastPart0L then
LeftGrip.Part0 = LastPart0L
end
if RightGrip and LastPart0R then
RightGrip.Part0 = LastPart0R
end
if ShowViewmodel then
ShowViewmodel = false
SetViewmodelVisible(ShowViewmodel)
end
end
if RigType == "R15" then
VMRoot.Transform = Root.Transform
VMWaist.Transform = Waist.Transform
VMLeftShoulder.Transform = LeftShoulder.Transform
VMRightShoulder.Transform = RightShoulder.Transform
VMLeftElbow.Transform = LeftElbow.Transform
VMLeftWrist.Transform = LeftWrist.Transform
VMRightElbow.Transform = RightElbow.Transform
VMRightWrist.Transform = RightWrist.Transform
elseif RigType == "R6" then
VMRootHip.Transform = RootHip.Transform
VMLeftShoulder.Transform = LeftShoulder.Transform
VMRightShoulder.Transform = RightShoulder.Transform
end
end)
Humanoid.Died:Connect(function()
Disable()
end)
Humanoid.AncestryChanged:Connect(function()
if not Humanoid:IsDescendantOf(game) then
Disable()
end
end)
--Viewmodel.Parent = Camera