local a=20 local d=19 local T=.5 local j=game:GetService("\082\117\110\083\101\114\118\105\099\101")local D=require(((game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")):WaitForChild("\080\114\111\106\101\099\116")):WaitForChild("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101"))local p=D:GetResource("\069\120\116\101\114\110\097\108\085\116\105\108\046\078\101\120\117\115\073\110\115\116\097\110\099\101\046\078\101\120\117\115\079\098\106\101\099\116")local X=D:GetObjectReference("\071\097\109\101\068\097\116\097\046\073\116\101\109\046\073\116\101\109\115")local G=D:GetResource("\082\049\053\067\104\097\114\097\099\116\101\114\077\111\100\101\108")local B=p:Extend()B:SetClassName("\080\108\097\121\101\114\068\105\115\112\108\097\121")function B.__new(p,D)p:InitializeSuper()p.PreviousLimbs={}p.PreviousLimbChanges={}local X=Instance.new("\086\105\101\119\112\111\114\116\070\114\097\109\101")X.BackgroundTransparency=1 X.Size=UDim2.new(1,0,1,0)X.Parent=D p.ViewportFrame=X local B=Instance.new("\067\097\109\101\114\097")B.FieldOfView=a B.Parent=X p.Camera=B X.CurrentCamera=B local g=Instance.new("\087\111\114\108\100\077\111\100\101\108")g.Parent=X p.Character=G:Clone()p.Character.PrimaryPart=p.Character:WaitForChild("\072\117\109\097\110\111\105\100\082\111\111\116\080\097\114\116")p.Character:SetPrimaryPartCFrame(CFrame.Angles(0,math.pi,0))p.Head=p.Character:WaitForChild("\072\101\097\100")local m=Instance.new("\066\111\100\121\067\111\108\111\114\115")m.HeadColor=BrickColor.new("\066\114\105\103\104\116 \121\101\108\108\111\119")m.LeftArmColor=BrickColor.new("\066\114\105\103\104\116 \121\101\108\108\111\119")m.RightArmColor=BrickColor.new("\066\114\105\103\104\116 \121\101\108\108\111\119")m.TorsoColor=BrickColor.new("\066\114\105\103\104\116 \103\114\101\101\110")m.LeftLegColor=BrickColor.new("\066\114\105\103\104\116 \098\108\117\101")m.RightLegColor=BrickColor.new("\066\114\105\103\104\116 \098\108\117\101")m.Parent=p.Character p.Character.Parent=g local H=Instance.new("\065\110\105\109\097\116\105\111\110")H.AnimationId="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\057\049\051\051\055\054\050\050\048"local V=p.Character:WaitForChild("\072\117\109\097\110\111\105\100")p.Humanoid=V local R=V:LoadAnimation(H)R.Stopped:Connect(function()R:Play()end)R:Play()j.RenderStepped:Connect(function()B.CFrame=CFrame.Angles(0,math.sin(tick()*T)/2,0)*CFrame.new(0,0,d)end)end function B.SetHat(d,a)local T if a then T=a.Name end if d.CurrentHatName==T then return end d.CurrentHatName=T if d.CurrentHat then d.CurrentHat:Destroy()end if T then local a=X:FindFirstChild(T)if a then local T=a:FindFirstChildWhichIsA("\065\099\099\111\117\116\114\101\109\101\110\116")if T then local a=T:Clone()a.Parent=d.Character d.CurrentHat=a local j=a:FindFirstChild("\072\097\110\100\108\101")local D=j:FindFirstChildWhichIsA("\065\116\116\097\099\104\109\101\110\116")if D and j then local a=d.Head:FindFirstChild(D.Name)if a then local T=Instance.new("\087\101\108\100")T.Part0=d.Head T.Part1=j T.C0=a.CFrame T.C1=D.CFrame T.Parent=d.Head end end end end end end function B.SetItem(T,a,d)local j if d then j=d.Name end if T.PreviousLimbs[a]==j then return end T.PreviousLimbs[a]=j local D={}if j then local a=X:FindFirstChild(j)if a then local d=a:FindFirstChild("\082\049\053")if d then for a,d in pairs(d:GetChildren())do if d:IsA("\066\097\115\101\080\097\114\116")then local a=Enum.BodyPartR15[d.Name]T.Humanoid:ReplaceBodyPartR15(a,d:Clone())D[a]=d.Name end end end end end local p=T.PreviousLimbChanges[a]if p then for a,d in pairs(p)do if not D[a]then local j=G:FindFirstChild(d)if j then T.Humanoid:ReplaceBodyPartR15(a,j:Clone())end end end end T.PreviousLimbChanges[a]=D end return B
--[[
TheNexusAvenger

Displays the player for the inventory.
--]]

local CAMERA_FIELD_OF_VIEW = 20
local CAMERA_CFRAME_BACK = 19
local ROTATE_SPEED_MULTIPLIER = 0.5



local RunService = game:GetService("RunService")

local ReplicatedStorageProject = require(game:GetService("ReplicatedStorage"):WaitForChild("Project"):WaitForChild("ReplicatedStorage"))

local NexusObject = ReplicatedStorageProject:GetResource("ExternalUtil.NexusInstance.NexusObject")
local ItemDataModule = ReplicatedStorageProject:GetObjectReference("GameData.Item.Items")
local R15CharacterModel = ReplicatedStorageProject:GetResource("R15CharacterModel")

local PlayerDisplay = NexusObject:Extend()
PlayerDisplay:SetClassName("PlayerDisplay")



--[[
Creates a player display.
--]]
function PlayerDisplay:__new(Parent)
    self:InitializeSuper()

    --Store the state.
    self.PreviousLimbs = {}
    self.PreviousLimbChanges = {}

    --Create the container.
    local ViewportFrame = Instance.new("ViewportFrame")
    ViewportFrame.BackgroundTransparency = 1
    ViewportFrame.Size = UDim2.new(1,0,1,0)
    ViewportFrame.Parent = Parent
    self.ViewportFrame = ViewportFrame

    local Camera = Instance.new("Camera")
    Camera.FieldOfView = CAMERA_FIELD_OF_VIEW
    Camera.Parent = ViewportFrame
    self.Camera = Camera
    ViewportFrame.CurrentCamera = Camera

    --Create the character.
    local WorldModel = Instance.new("WorldModel")
    WorldModel.Parent = ViewportFrame

    self.Character = R15CharacterModel:Clone()
    self.Character.PrimaryPart = self.Character:WaitForChild("HumanoidRootPart")
    self.Character:SetPrimaryPartCFrame(CFrame.Angles(0,math.pi,0))
    self.Head = self.Character:WaitForChild("Head")

    local BodyColors = Instance.new("BodyColors")
    BodyColors.HeadColor = BrickColor.new("Bright yellow")
    BodyColors.LeftArmColor = BrickColor.new("Bright yellow")
    BodyColors.RightArmColor = BrickColor.new("Bright yellow")
    BodyColors.TorsoColor = BrickColor.new("Bright green")
    BodyColors.LeftLegColor = BrickColor.new("Bright blue")
    BodyColors.RightLegColor = BrickColor.new("Bright blue")
    BodyColors.Parent = self.Character
    self.Character.Parent = WorldModel

    --Start the animation.
    local Animation = Instance.new("Animation")
    Animation.AnimationId = "http://www.roblox.com/asset/?id=913376220"

    local Humanoid = self.Character:WaitForChild("Humanoid")
    self.Humanoid = Humanoid
    local AnimationTrack = Humanoid:LoadAnimation(Animation)
    AnimationTrack.Stopped:Connect(function()
        AnimationTrack:Play()
    end)
    AnimationTrack:Play()

    --Start rotating the camera.
    RunService.RenderStepped:Connect(function()
        Camera.CFrame = CFrame.Angles(0,math.sin(tick() * ROTATE_SPEED_MULTIPLIER)/2,0) * CFrame.new(0,0,CAMERA_CFRAME_BACK)
    end)
end

--[[
Sets the hat to wear.
--]]
function PlayerDisplay:SetHat(HatItem)
    --Get the hat name.
    local HatName
    if HatItem then
        HatName = HatItem.Name
    end

    --Return if the hat hasn't changed.
    if self.CurrentHatName == HatName then
        return
    end
    self.CurrentHatName = HatName

    --Clear the existing hat.
    if self.CurrentHat then
        self.CurrentHat:Destroy()
    end

    --Add the new hat.
    if HatName then
        local HatModel = ItemDataModule:FindFirstChild(HatName)
        if HatModel then
            local Hat = HatModel:FindFirstChildWhichIsA("Accoutrement")
            if Hat then
                --Add the new hat.
                local NewHat = Hat:Clone()
                NewHat.Parent = self.Character
                self.CurrentHat = NewHat

                --Weld the hat to the character.
                --This isn't done automatically by WorldModels.
                local Handle = NewHat:FindFirstChild("Handle")
                local HatAttachment = Handle:FindFirstChildWhichIsA("Attachment")
                if HatAttachment and Handle then
                    local HeadAttachment = self.Head:FindFirstChild(HatAttachment.Name)
                    if HeadAttachment then
                        local HatWeld = Instance.new("Weld")
                        HatWeld.Part0 = self.Head
                        HatWeld.Part1 = Handle
                        HatWeld.C0 = HeadAttachment.CFrame
                        HatWeld.C1 = HatAttachment.CFrame
                        HatWeld.Parent = self.Head
                    end
                end
            end
        end
    end
end

--[[
Sets the limb to use.
--]]
function PlayerDisplay:SetItem(LimbName,Item)
    --Get the hat name.
    local ItemName
    if Item then
        ItemName = Item.Name
    end

    --Return if the limb hasn't changed.
    if self.PreviousLimbs[LimbName] == ItemName then
        return
    end
    self.PreviousLimbs[LimbName] = ItemName

    --Set the limb.
    local BodyPartsChanged = {}
    if ItemName then
        local LimbModel = ItemDataModule:FindFirstChild(ItemName)
        if LimbModel then
            local LimbModelR15 = LimbModel:FindFirstChild("R15")
            if LimbModelR15 then
                for _,Part in pairs(LimbModelR15:GetChildren()) do
                    if Part:IsA("BasePart") then
                        local BodyPartEnum = Enum.BodyPartR15[Part.Name]
                        self.Humanoid:ReplaceBodyPartR15(BodyPartEnum,Part:Clone())
                        BodyPartsChanged[BodyPartEnum] = Part.Name
                    end
                end
            end
        end
    end

    --Revert the unchanged limb parts.
    local ExistingLimbChanges = self.PreviousLimbChanges[LimbName]
    if ExistingLimbChanges then
        for BodyPartEnum,PartName in pairs(ExistingLimbChanges) do
            if not BodyPartsChanged[BodyPartEnum] then
                local Part = R15CharacterModel:FindFirstChild(PartName)
                if Part then
                    self.Humanoid:ReplaceBodyPartR15(BodyPartEnum,Part:Clone())
                end
            end
        end
    end
    self.PreviousLimbChanges[LimbName] = BodyPartsChanged
end



return PlayerDisplay