In a new FPS game I am making with a friend we wanted to way to create arm animations while in first person camera mode. I researched and found that I should create a client side clone of the limbs that aren’t automatically disabled by first person camera mode, and did this. The thing about this though is the way I did it led to a few bugs.
First, primarily, is during a server test of the actual game, whenever a character dies a few times or resets a few times the arms just stop cloning, or they create lifeless clones. The system essentially uses a remote event that when a player leaves the menu screen, the camera is fixed to first person and the arms are cloned from the character, then a constant while true is updating the CFrame of the arms so that they appear to be in camera. Additionally after a character dies, they’re clone limbs are destroyed and then cloned again when the character is destroyed when it respawns.
Another problem is that there is a small bit of latency updating the CFrame of the clones to the actual arms, is there an alternative way to do this so that animating/holding tools looks better?
EDIT: Also forgot to mention, whenever you shoot and move at the same time the CFrame glitches because of the recoil, I’m unsure how I go about changing that.
local plr = game.Players.LocalPlayer
local chr = plr.Character or plr.CharacterAdded:Wait()
local cam = workspace.CurrentCamera
local ev = game:GetService("ReplicatedStorage"):WaitForChild("Requests"):WaitForChild("FixCamera")
local leftArm
local rightArm
ev.OnClientEvent:Connect(function()
cam.CameraType = "Custom"
plr.CameraMode = Enum.CameraMode.LockFirstPerson
local mouse = plr:GetMouse()
repeat task.wait()
mouse.Icon = "rbxassetid://9947313248"
until mouse.Icon == "rbxassetid://9947313248"
end)
local function CloneArms()
for i, v in plr.Character:GetChildren() do
if v.Name == "Right Arm" then
rightArm = v:Clone()
elseif v.Name == "Left Arm" then
leftArm = v:Clone()
end
end
rightArm.Parent = game.Workspace
rightArm.Anchored = true
rightArm.Material = Enum.Material.SmoothPlastic
rightArm.CanCollide = false
rightArm.Name = "ClonedRight"
leftArm.Parent = game.Workspace
leftArm.Anchored = true
leftArm.Material = Enum.Material.SmoothPlastic
leftArm.CanCollide = false
leftArm.Name = "ClonedLeft"
end
plr.CharacterAdded:Connect(function()
plr.CharacterAdded:Wait()
repeat task.wait()
CloneArms()
until game.Workspace:FindFirstChild("ClonedRight")
while true do task.wait()
for i, v in plr.Character:GetChildren() do
if v.Name == "Right Arm" then
rightArm.CFrame = v.CFrame
elseif v.Name == "Left Arm" then
leftArm.CFrame = v.CFrame
end
end
if plr.Character:FindFirstChild("Humanoid").Health == 0 then
leftArm:Destroy()
rightArm:Destroy()
break
end
end
end)
ev.OnClientEvent:Connect(function()
while wait() do
repeat task.wait()
until plr.Character:FindFirstChild("Humanoid").Health ~= 0
CloneArms()
while true do task.wait()
for i, v in plr.Character:GetChildren() do
if v.Name == "Right Arm" then
rightArm.CFrame = v.CFrame
elseif v.Name == "Left Arm" then
leftArm.CFrame = v.CFrame
end
end
if plr.Character:FindFirstChild("Humanoid").Health == 0 then
leftArm:Destroy()
rightArm:Destroy()
break
end
end
end
end)
Video of issue:
[2023-06-18 16-17-59.mp4 - Google Drive]