I dont even know what to say here, ive many a few other posts on this which have only led me into more problems
Cant figure out how to setup this viewmodel so it can be animated, the limbs just all teleport into the root part after hooking up the motors, not sure what to even do to try and combat this.
Heres the code
(edit, Updated)
local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
Character.Archivable = true
repeat task.wait() until game:IsLoaded()
local sf = string.find
local viewmodel = Instance.new("Model")
viewmodel.Name = "ViewModel"
local ClonedChar = Character:Clone()
local RootPart
for Num, Part in ipairs(ClonedChar:GetChildren()) do
local name = Part.Name:lower()
if not sf(name, "hand") and not sf(name, "arm") and not sf(name, "head") then
if not Part:IsA("Humanoid") and not Part:IsA("Shirt") and not string.find(Part.Name:lower(), "root") then
Part:Destroy()
elseif Part:IsA("Humanoid") then
Part.Parent = viewmodel
for i, v in ipairs(Part:GetChildren()) do
if not v:IsA("Animator") then v:Destroy()end
end
elseif string.find(Part.Name:lower(), "root") then
RootPart = Part
Part.Parent = nil
Part.Size = Vector3.new(.75,.75,.75)
Part.CanCollide = false
Part.CanQuery = false
Part.CanTouch = false
Part.Transparency = 1
Part.Anchored = true
else
Part.Parent = viewmodel
end
else
if not Part:IsA("MeshPart") then
Part:Destroy()
else
Part.Anchored = true
Part.Parent = viewmodel
for i, v in ipairs(Part:GetChildren()) do
if not v:IsA("Motor6D") then
v:Destroy()
end
end
end
end
end
ClonedChar:Destroy()
viewmodel.Parent = workspace.Camera
local Humanoid = viewmodel:WaitForChild("Humanoid")
local CameraPart = Instance.new("Part"); CameraPart.Name = "CameraPart"
CameraPart.Anchored = true
CameraPart.CanCollide = false
CameraPart.Size = Vector3.new(.75,.75,.75)
CameraPart.Parent = viewmodel
CameraPart.CFrame = viewmodel:WaitForChild("Head").CFrame
viewmodel:WaitForChild("Head"):Destroy()
Humanoid.Parent = nil
RootPart.Parent = viewmodel
RootPart.CFrame = CameraPart.CFrame
local LeftHand = viewmodel:WaitForChild("LeftHand")
local LeftLowerArm = viewmodel:WaitForChild("LeftLowerArm")
local LeftUpperArm = viewmodel:WaitForChild("LeftUpperArm")
local RightHand = viewmodel:WaitForChild("RightHand")
local RightLowerArm = viewmodel:WaitForChild("RightLowerArm")
local RightUpperArm = viewmodel:WaitForChild("RightUpperArm")
local Rpp = RootPart.Position
local LA = LeftUpperArm.Position
local RA = RightUpperArm.Position
local LArmOffset = Vector3.new(
Rpp.X - LA.x,
-(Rpp.Y - LA.Y),
Rpp.Z - LA.Z
)
local RArmOffset = Vector3.new(
Rpp.X - RA.x,
-(Rpp.Y - RA.Y),
Rpp.Z - RA.Z
)
print(RArmOffset)
local Rshoulder = RightUpperArm:FindFirstChild("RightShoulder")
local Lshoulder = LeftUpperArm:FindFirstChild("LeftShoulder")
Rshoulder.Part0 = RootPart
Lshoulder.Part0 = RootPart
Rshoulder.C0 = CFrame.new(RArmOffset)
Lshoulder.C0 = CFrame.new(LArmOffset)
Rshoulder.C1 = CFrame.new(0,0,0)
Lshoulder.C1 = CFrame.new(0,0,0)
local Motor3 = Instance.new("Motor6D")
Motor3.Parent = RootPart
Motor3.Part0 = RootPart
Motor3.Part1 = CameraPart
Humanoid.Parent = viewmodel
for i, v in ipairs(viewmodel:GetChildren()) do
local Name = v.Name:lower()
if not string.find(Name, "root") and v:IsA("MeshPart") then
v.Anchored = false
end
end