Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Do not remove the following line. Used by Plugin by TheNexusAvenger to check if R15 is already ingame.
- --R15PortVersionB_
- local UseShirtHack = false --If true, creates decals to have shirts/pants have proper limb coloring
- --The admins will fix it soonish, but for now it isn't
- local ModifyHats = false --If true, it will move the hats a little bit to fit the head
- --The admins will fix it soonish, but for now it isn't
- local function CreateR15Model()
- local R15Model = Instance.new("Model")
- R15Model.Name = "StarterCharacter"
- local Humanoid = Instance.new("Humanoid")
- Humanoid.HipHeight = 1.8
- Humanoid.Parent = R15Model
- local function CreateLimb(Name,Color,Size,Transparency,ConnectToLimb,MotorName,C0,C1,MeshId)
- local Part = Instance.new("Part")
- Part.FormFactor = "Custom"
- Part.Size = Size
- Part.BrickColor = Color
- Part.CanCollide = false
- Part.Name = Name
- Part.Transparency = (Transparency == 0.001 and 0 or Transparency)
- Part.TopSurface = "Smooth"
- Part.BottomSurface = "Smooth"
- if ConnectToLimb then
- local Motor = Instance.new("Motor6D")
- Motor.C0 = C0
- Motor.C1 = C1
- Motor.Part0 = ConnectToLimb
- Motor.Part1 = Part
- Motor.Name = MotorName
- Motor.MaxVelocity = 0.1
- Motor.Parent = ConnectToLimb
- end
- if MeshId then
- local Mesh = Instance.new("SpecialMesh")
- Mesh.MeshType = "FileMesh"
- Mesh.Name = "LimbMesh"
- Mesh.MeshId = MeshId
- Mesh.Parent = Part
- end
- if MeshId and Transparency == 0.001 then
- if UseShirtHack == true then
- local Decal = Instance.new("Decal")
- Decal.Name = "ShirtDecal"
- Decal.Parent = Part
- end
- end
- Part.Parent = R15Model
- return Part
- end
- local function AddAttachment(Name,Parent,Position,Rotation,Axis,SecondaryAxis)
- local Attachment = Instance.new("Attachment")
- Attachment.Position = Position
- Attachment.Rotation = Rotation
- Attachment.Axis = Axis
- Attachment.SecondaryAxis = SecondaryAxis
- Attachment.Parent = Parent
- end
- local HumanoidRootPart = CreateLimb("HumanoidRootPart",BrickColor.new("Medium stone grey"),Vector3.new(1,1,1),1)
- local LowerTorso = CreateLimb("LowerTorso",BrickColor.new("Bright blue"),Vector3.new(1,1,1),0.001,HumanoidRootPart,"RootJoint",CFrame.new(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1),CFrame.new(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1),"rbxassetid://387941715")
- local UpperTorso = CreateLimb("UpperTorso",BrickColor.new("Bright blue"),Vector3.new(1,1,1),0.001,LowerTorso,"Waist",CFrame.new(0, 0.404105991, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1),CFrame.new(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1),"rbxassetid://387941468")
- local Head = CreateLimb("Head",BrickColor.new("Bright yellow"),Vector3.new(1,1,1),0,UpperTorso,"Neck",CFrame.new(0, 1.26949596, 0.0428609997, 1, 0, 0, 0, 1, 0, 0, 0, 1),CFrame.new(0, -0.635110021, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1),"rbxassetid://387941905")
- local LeftUpperArm = CreateLimb("LeftUpperArm",BrickColor.new("Bright yellow"),Vector3.new(1, 0.672, 1),0.001,UpperTorso,"LeftShoulder",CFrame.new(-1.50177097, 0.924546003, 0, 1, 0, -0, 0, 0.999044001, 0.0437170006, 0, -0.0437170006, 0.999044001),CFrame.new(0, 0.336115986, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1),"rbxassetid://387938468")
- local LeftLowerArm = CreateLimb("LeftLowerArm",BrickColor.new("Bright yellow"),Vector3.new(1, 0.703, 1),0.001,LeftUpperArm,"LeftElbow",CFrame.new(0, -0.336115986, 0, 1, 0, 0, 0, 0.999044001, -0.0437170006, 0, 0.0437170006, 0.999044001),CFrame.new(0, 0.351512015, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1),"rbxassetid://387938971")
- local LeftHand = CreateLimb("LeftHand",BrickColor.new("Bright yellow"),Vector3.new(1, 0.352, 1),0.001,LeftLowerArm,"LeftWrist",CFrame.new(0, -0.351512015, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1),CFrame.new(0, 0.175756007, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1),"rbxassetid://387939233")
- local RightUpperArm = CreateLimb("RightUpperArm",BrickColor.new("Bright yellow"),Vector3.new(1, 0.671, 1),0.001,UpperTorso,"RightShoulder",CFrame.new(1.50049305, 0.923726022, 0, 1, 0, -0, 0, 0.999041617, 0.0437709838, 0, -0.0437709838, 0.999041617),CFrame.new(0, 0.335705996, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1),"rbxassetid://387940113")
- local RightLowerArm = CreateLimb("RightLowerArm",BrickColor.new("Bright yellow"),Vector3.new(1, 0.703, 1),0.001,RightUpperArm,"RightElbow",CFrame.new(0, -0.335705996, 0, 1, 0, 0, 0, 0.999041617, -0.0437709838, 0, 0.0437709838, 0.999041617),CFrame.new(0, 0.351512015, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1),"rbxassetid://387940356")
- local RightHand = CreateLimb("RightHand",BrickColor.new("Bright yellow"),Vector3.new(1, 0.352, 1),0.001,RightLowerArm,"RightWrist",CFrame.new(0, -0.351512015, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1),CFrame.new(0, 0.175756007, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1),"rbxassetid://387940548")
- local LeftUpperLeg = CreateLimb("LeftUpperLeg",BrickColor.new("Br. yellowish green"),Vector3.new(1, 0.775, 1),0.001,LowerTorso,"LeftHip",CFrame.new(-0.457044005, -0.498115987, 0, 1, 0, -0, 0, 1, 0.000100999998, 0, -0.000100999998, 1),CFrame.new(0, 0.387418985, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1),"rbxassetid://387939645")
- local LeftLowerLeg = CreateLimb("LeftLowerLeg",BrickColor.new("Br. yellowish green"),Vector3.new(1, 0.829, 1),0.001,LeftUpperLeg,"LeftKnee",CFrame.new(0, -0.387418985, 0, 1, 9.95820074e-007, 9.13360125e-008, -9.99999997e-007, 0.995820105, 0.0913360119, 0, -0.0913360119, 0.995820105),CFrame.new(0, 0.414570987, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1),"rbxassetid://387939489")
- local LeftFoot = CreateLimb("LeftFoot",BrickColor.new("Br. yellowish green"),Vector3.new(1, 0.415, 1),0.001,LeftLowerLeg,"LeftAnkle",CFrame.new(0, -0.414570987, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1),CFrame.new(0, 0.207286, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1),"rbxassetid://387939912")
- local RightUpperLeg = CreateLimb("RightUpperLeg",BrickColor.new("Br. yellowish green"),Vector3.new(1, 0.775, 1),0.001,LowerTorso,"RightHip",CFrame.new(0.451141, -0.498115987, 0, 1, 0, -0, 0, 1, 0.000100999998, 0, -0.000100999998, 1),CFrame.new(0, 0.387418985, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1),"rbxassetid://387940976")
- local RightLowerLeg = CreateLimb("RightLowerLeg",BrickColor.new("Br. yellowish green"),Vector3.new(1, 0.829, 1),0.001,RightUpperLeg,"RightKnee",CFrame.new(0, -0.387418985, 0, 1, 0, -0, 0, 0.995820105, 0.0913360119, 0, -0.0913360119, 0.995820105),CFrame.new(0, 0.414570987, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1),"rbxassetid://387940802")
- local RightFoot = CreateLimb("RightFoot",BrickColor.new("Br. yellowish green"),Vector3.new(1, 0.415, 1),0.001,RightLowerLeg,"RightAnkle",CFrame.new(0, -0.414570987, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1),CFrame.new(0, 0.207286, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1),"rbxassetid://387941196")
- local Torso = CreateLimb("Torso",BrickColor.new("Bright blue"),Vector3.new(1,1,1),1)
- local RightArm = CreateLimb("Right Arm",BrickColor.new("Bright yellow"),Vector3.new(0.2,0.2,0.2),1,RightHand,"ToolGripConnector",CFrame.new(0,0.824,0),CFrame.new(0,0,0))
- local LeftArm = CreateLimb("Left Arm",BrickColor.new("Bright yellow"),Vector3.new(0.2,0.2,0.2),1,LeftHand,"ToolGripConnector",CFrame.new(0,0.824,0),CFrame.new(0,0,0))
- AddAttachment("NeckRigAttachment",Head,Vector3.new(0, -0.635110021, 0),Vector3.new(-0, 0, -0),Vector3.new(1, 0, 0),Vector3.new(0, 1, 0))
- AddAttachment("HatAttachment",Head,Vector3.new(0.00058599998, 0.502066016, -0.0712800026),Vector3.new(-0, 0, -0),Vector3.new(1, 0, 0),Vector3.new(0, 1, 0))
- AddAttachment("HairAttachment",Head,Vector3.new(0.00058599998, 0.502066016, -0.0712800026),Vector3.new(-0, 0, -0),Vector3.new(1, 0, 0),Vector3.new(0, 1, 0))
- AddAttachment("FaceAttachment",Head,Vector3.new(0.0161419995, -0.0170900002, -0.671580017),Vector3.new(-0, 0, -0),Vector3.new(1, 0, 0),Vector3.new(0, 1, 0))
- AddAttachment("NeckAttachment",Head,Vector3.new(0.000548999989, -0.689900994, -0.025719),Vector3.new(-0, 0, -0),Vector3.new(1, 0, 0),Vector3.new(0, 1, 0))
- AddAttachment("RootRigAttachment",HumanoidRootPart,Vector3.new(0, 0, 0),Vector3.new(-0, 0, -0),Vector3.new(1, 0, 0),Vector3.new(0, 1, 0))
- AddAttachment("LeftElbowRigAttachment",LeftLowerArm,Vector3.new(0, 0.351512015, 0),Vector3.new(-0, 0, -0),Vector3.new(1, 0, 0),Vector3.new(0, 1, 0))
- AddAttachment("LeftWristRigAttachment",LeftLowerArm,Vector3.new(0, -0.351512015, 0),Vector3.new(-0, 0, -0),Vector3.new(1, 0, 0),Vector3.new(0, 1, 0))
- AddAttachment("LeftShoulderRigAttachment",LeftUpperArm,Vector3.new(0, 0.336115986, 0),Vector3.new(-0, 0, -0),Vector3.new(1, 0, 0),Vector3.new(0, 1, 0))
- AddAttachment("LeftElbowRigAttachment",LeftUpperArm,Vector3.new(0, -0.336115986, 0),Vector3.new(2.50559807, 0, -0),Vector3.new(1, 0, 0),Vector3.new(0, 0.999044001, 0.0437170006))
- AddAttachment("LeftAnkleRigAttachment",LeftFoot,Vector3.new(0, 0.207286, 0),Vector3.new(-0, 0, -0),Vector3.new(1, 0, 0),Vector3.new(0, 1, 0))
- AddAttachment("LeftWristRigAttachment",LeftHand,Vector3.new(0, 0.175756007, 0),Vector3.new(-0, 0, -0),Vector3.new(1, 0, 0),Vector3.new(0, 1, 0))
- AddAttachment("LeftGripAttachment",LeftHand,Vector3.new(0, -0.162433997, 0),Vector3.new(-90, -0, -0),Vector3.new(1, 0, 0),Vector3.new(0, 0, -1))
- AddAttachment("LeftKneeRigAttachment",LeftLowerLeg,Vector3.new(0, 0.414570987, 0),Vector3.new(-0, 0, -0),Vector3.new(1, 0, 0),Vector3.new(0, 1, 0))
- AddAttachment("LeftAnkleRigAttachment",LeftLowerLeg,Vector3.new(0, -0.414570987, 0),Vector3.new(-0, 0, -0),Vector3.new(1, 0, 0),Vector3.new(0, 1, 0))
- AddAttachment("LeftHipRigAttachment",LeftUpperLeg,Vector3.new(0, 0.387418985, 0),Vector3.new(-0, 0, -0),Vector3.new(1, 0, 0),Vector3.new(0, 1, 0))
- AddAttachment("LeftKneeRigAttachment",LeftUpperLeg,Vector3.new(0, -0.387418985, 0),Vector3.new(-5.24047184, 5.23316794e-006, -5.70562879e-005),Vector3.new(1, -9.99999997e-007, 0),Vector3.new(9.95820074e-007, 0.995820105, -0.0913360119))
- AddAttachment("RightElbowRigAttachment",RightLowerArm,Vector3.new(0, 0.351512015, 0),Vector3.new(-0, 0, -0),Vector3.new(1, 0, 0),Vector3.new(0, 1, 0))
- AddAttachment("RightWristRigAttachment",RightLowerArm,Vector3.new(0, -0.351512015, 0),Vector3.new(-0, 0, -0),Vector3.new(1, 0, 0),Vector3.new(0, 1, 0))
- AddAttachment("RightShoulderRigAttachment",RightUpperArm,Vector3.new(0, 0.335705996, 0),Vector3.new(-0, 0, -0),Vector3.new(1, 0, 0),Vector3.new(0, 1, 0))
- AddAttachment("RightElbowRigAttachment",RightUpperArm,Vector3.new(0, -0.335705996, 0),Vector3.new(2.50869417, 0, -0),Vector3.new(1, 0, 0),Vector3.new(0, 0.999041617, 0.0437709838))
- AddAttachment("RightAnkleRigAttachment",RightFoot,Vector3.new(0, 0.207286, 0),Vector3.new(-0, 0, -0),Vector3.new(1, 0, 0),Vector3.new(0, 1, 0))
- AddAttachment("RightWristRigAttachment",RightHand,Vector3.new(0, 0.175756007, 0),Vector3.new(-0, 0, -0),Vector3.new(1, 0, 0),Vector3.new(0, 1, 0))
- AddAttachment("RightGripAttachment",RightHand,Vector3.new(0, -0.162433997, 0),Vector3.new(-90, -0, -0),Vector3.new(1, 0, 0),Vector3.new(0, 0, -1))
- AddAttachment("RightKneeRigAttachment",RightLowerLeg,Vector3.new(0, 0.414570987, 0),Vector3.new(-0, 0, -0),Vector3.new(1, 0, 0),Vector3.new(0, 1, 0))
- AddAttachment("RightAnkleRigAttachment",RightLowerLeg,Vector3.new(0, -0.414570987, 0),Vector3.new(-0, 0, -0),Vector3.new(1, 0, 0),Vector3.new(0, 1, 0))
- AddAttachment("RightHipRigAttachment",RightUpperLeg,Vector3.new(0, 0.387418985, 0),Vector3.new(-0, 0, -0),Vector3.new(1, 0, 0),Vector3.new(0, 1, 0))
- AddAttachment("RightKneeRigAttachment",RightUpperLeg,Vector3.new(0, -0.387418985, 0),Vector3.new(-5.24047184, -0, -0),Vector3.new(1, 0, 0),Vector3.new(0, 0.995820105, -0.0913360119))
- AddAttachment("WaistRigAttachment",UpperTorso,Vector3.new(0, 0, 0),Vector3.new(-0, 0, -0),Vector3.new(1, 0, 0),Vector3.new(0, 1, 0))
- AddAttachment("NeckRigAttachment",UpperTorso,Vector3.new(0, 1.26949596, 0.0428609997),Vector3.new(-0, 0, -0),Vector3.new(1, 0, 0),Vector3.new(0, 1, 0))
- AddAttachment("LeftShoulderRigAttachment",UpperTorso,Vector3.new(-1.50177097, 0.924546003, 0),Vector3.new(-2.50559807, -0, -0),Vector3.new(1, 0, 0),Vector3.new(0, 0.999044001, -0.0437170006))
- AddAttachment("RightShoulderRigAttachment",UpperTorso,Vector3.new(1.50049305, 0.923726022, 0),Vector3.new(-2.50869417, -0, -0),Vector3.new(1, 0, 0),Vector3.new(0, 0.999041617, -0.0437709838))
- AddAttachment("BodyBackAttachment",UpperTorso,Vector3.new(0.000597000006, 0.362652004, 0.488660008),Vector3.new(-0, 0, -0),Vector3.new(1, 0, 0),Vector3.new(0, 1, 0))
- AddAttachment("BodyFrontAttachment",UpperTorso,Vector3.new(0.00511999987, 0.606338978, -0.510424972),Vector3.new(-0, 0, -0),Vector3.new(1, 0, 0),Vector3.new(0, 1, 0))
- AddAttachment("ShoulderAttachment",UpperTorso,Vector3.new(-0.797239006, 1.21844196, -0.00955600012),Vector3.new(-0, 0, -0),Vector3.new(1, 0, 0),Vector3.new(0, 1, 0))
- AddAttachment("RootRigAttachment",LowerTorso,Vector3.new(0, 0, 0),Vector3.new(-0, 0, -0),Vector3.new(1, 0, 0),Vector3.new(0, 1, 0))
- AddAttachment("WaistRigAttachment",LowerTorso,Vector3.new(0, 0.404105991, 0),Vector3.new(-0, 0, -0),Vector3.new(1, 0, 0),Vector3.new(0, 1, 0))
- AddAttachment("LeftHipRigAttachment",LowerTorso,Vector3.new(-0.457044005, -0.498115987, 0),Vector3.new(-0.00578687387, -0, -0),Vector3.new(1, 0, 0),Vector3.new(0, 1, -0.000100999998))
- AddAttachment("RightHipRigAttachment",LowerTorso,Vector3.new(0.451141, -0.498115987, 0),Vector3.new(-0.00578687387, -0, -0),Vector3.new(1, 0, 0),Vector3.new(0, 1, -0.000100999998))
- AddAttachment("WaistAttachment",LowerTorso,Vector3.new(0.00511999987, 0.00413900008, -0.510424972),Vector3.new(-0, 0, -0),Vector3.new(1, 0, 0),Vector3.new(0, 1, 0))
- R15Model.PrimaryPart = HumanoidRootPart
- return R15Model
- end
- local Animate = script:WaitForChild("Animate")
- local R15Fixes = script:WaitForChild("R15Fixes")
- local StarterPlayer = game:GetService("StarterPlayer")
- local R15Model = CreateR15Model()
- local NewAnimate = Animate:Clone()
- NewAnimate.Disabled = false
- NewAnimate.Parent = StarterPlayer:WaitForChild("StarterCharacterScripts")
- local NewR15Fixes = R15Fixes:Clone()
- NewR15Fixes.Disabled = false
- NewR15Fixes.Parent = R15Model
- if ModifyHats == true then
- local Bool = Instance.new("BoolValue")
- Bool.Name = "ModifyHats"
- Bool.Value = true
- Bool.Parent = NewR15Fixes
- end
- R15Model.Parent = StarterPlayer
- local Character = script.Parent
- local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
- local Torso = Character:WaitForChild("Torso")
- local Humanoid = Character:WaitForChild("Humanoid")
- local function ChildAddedJoint(Ins)
- if Ins:IsA("Motor6D") then
- if Ins.Part1 then
- if Ins.Part1.Name == "Right Arm" or Ins.Part1.Name == "Left Arm" then
- Ins.Part1 = nil
- elseif Ins.Part1.Name == "Torso" then
- Ins:Destroy()
- end
- end
- end
- end
- HumanoidRootPart.ChildAdded:connect(ChildAddedJoint)
- for _,Ins in pairs(HumanoidRootPart:GetChildren()) do
- spawn(function() ChildAddedJoint(Ins) end)
- end
- Torso.ChildAdded:connect(ChildAddedJoint)
- for _,Ins in pairs(Torso:GetChildren()) do
- spawn(function() ChildAddedJoint(Ins) end)
- end
- local Head = Character:WaitForChild("Head")
- local UpperTorso = Character:WaitForChild("UpperTorso")
- local RightUpperLeg = Character:WaitForChild("RightUpperLeg")
- local UpperTorsoDecal = UpperTorso:FindFirstChild("ShirtDecal")
- local UpperTorsoMesh
- if not UpperTorsoDecal then
- UpperTorsoMesh = UpperTorso:FindFirstChild("LimbMesh")
- end
- local RightUpperLegDecal = RightUpperLeg:FindFirstChild("ShirtDecal")
- local RightUpperLegMesh
- if not RightUpperLegDecal then
- RightUpperLegMesh = RightUpperLeg:FindFirstChild("LimbMesh")
- end
- local RightHand =Character:WaitForChild("RightHand")
- local Limbs = {
- Torso = {
- Character:WaitForChild("LowerTorso"),
- UpperTorso,
- },
- LeftArm = {
- Character:WaitForChild("LeftUpperArm"),
- Character:WaitForChild("LeftLowerArm"),
- Character:WaitForChild("LeftHand"),
- },
- RightArm = {
- Character:WaitForChild("RightUpperArm"),
- Character:WaitForChild("RightLowerArm"),
- RightHand,
- },
- LeftLeg = {
- Character:WaitForChild("LeftUpperLeg"),
- Character:WaitForChild("LeftLowerLeg"),
- Character:WaitForChild("LeftFoot"),
- },
- RightLeg = {
- Character:WaitForChild("RightUpperLeg"),
- Character:WaitForChild("RightLowerLeg"),
- Character:WaitForChild("RightFoot"),
- },
- }
- local function ChangePart(LimbName,Property)
- for _,Limb in pairs(Limbs[LimbName]) do
- if type(Property) == "string" then
- local ShirtDecal = Limb:FindFirstChild("ShirtDecal")
- if ShirtDecal then
- ShirtDecal.Texture = Property
- else
- local Mesh = Limb:FindFirstChild("LimbMesh")
- if Mesh then
- Mesh.TextureId = Property
- end
- end
- else
- Limb.BrickColor = Property
- end
- end
- end
- local RightGrip
- local function ChildAdded(Ins)
- if Ins:IsA("BodyColors") then
- Head.BrickColor = Ins.HeadColor
- ChangePart("Torso",Ins.TorsoColor)
- ChangePart("LeftArm",Ins.LeftArmColor)
- ChangePart("RightArm",Ins.RightArmColor)
- ChangePart("LeftLeg",Ins.LeftLegColor)
- ChangePart("RightLeg",Ins.RightLegColor)
- elseif Ins:IsA("Shirt") then
- ChangePart("Torso",Ins.ShirtTemplate)
- ChangePart("LeftArm",Ins.ShirtTemplate)
- ChangePart("RightArm",Ins.ShirtTemplate)
- elseif Ins:IsA("Pants") then
- if (UpperTorsoDecal and UpperTorsoDecal.Texture == "") or (UpperTorsoMesh and UpperTorsoMesh.TextureId == "") then
- ChangePart("Torso",Ins.PantsTemplate)
- ChangePart("LeftLeg",Ins.PantsTemplate)
- ChangePart("RightLeg",Ins.PantsTemplate)
- else
- ChangePart("LeftLeg",Ins.PantsTemplate)
- ChangePart("RightLeg",Ins.PantsTemplate)
- end
- end
- end
- local function ChildRemoved(Ins)
- if Ins:IsA("Shirt") then
- local PantsTexture = (RightUpperLegDecal and RightUpperLegDecal.Texture) or (RightUpperLegMesh and RightUpperLegMesh.TextureId)
- ChangePart("Torso",PantsTexture)
- ChangePart("LeftArm","")
- ChangePart("RightArm","")
- elseif Ins:IsA("Pants") then
- local ShirtTexture = (UpperTorsoDecal and UpperTorsoDecal.Texture) or (UpperTorsoMesh and UpperTorsoMesh.TextureId)
- ChangePart("LeftLeg","")
- ChangePart("RightLeg","")
- if ShirtTexture == Ins.PantsTemplate then ChangePart("Torso","") end
- end
- end
- Character.ChildAdded:connect(ChildAdded)
- Character.ChildRemoved:connect(ChildRemoved)
- for _,Ins in pairs(Character:GetChildren()) do
- spawn(function() ChildAdded(Ins) end)
- end
- if script:FindFirstChild("ModifyHats") then
- local function HeadWeldAdded(Ins)
- if Ins.Name == "HeadWeld" then
- Ins.C1 = CFrame.new(0,0,0.05) * Ins.C1
- end
- end
- Head.ChildAdded:connect(HeadWeldAdded)
- for _,Ins in pairs(Character:GetChildren()) do
- spawn(function() HeadWeldAdded(Ins) end)
- end
- end
- function waitForChild(parent, childName)
- local child = parent:findFirstChild(childName)
- if child then return child end
- while true do
- child = parent.ChildAdded:wait()
- if child.Name==childName then return child end
- end
- end
- local Figure = script.Parent
- local Humanoid = waitForChild(Figure, "Humanoid")
- local pose = "Standing"
- Humanoid.CameraOffset = Vector3.new(0,0.5,0)
- local currentAnim = ""
- local currentAnimInstance = nil
- local currentAnimTrack = nil
- local currentAnimKeyframeHandler = nil
- local currentAnimSpeed = 1.0
- local animTable = {}
- local animNames = {
- idle = {
- { id = "rbxasset://R15021216/idle_stretch.xml", weight = 1 },
- { id = "rbxasset://R15021216/idle_look.xml", weight = 1 },
- { id = "rbxasset://R15021216/idle.xml", weight = 9 }
- },
- walk = {
- { id = "rbxasset://R15021216/run.xml", weight = 10 }
- },
- run = {
- { id = "rbxasset://R15021216/run.xml", weight = 10 }
- },
- jump = {
- { id = "rbxasset://R15021216/jump.xml", weight = 10 }
- },
- fall = {
- { id = "rbxasset://R15021216/falling.xml", weight = 10 }
- },
- climb = {
- { id = "rbxasset://R15021216/climb.xml", weight = 10 }
- },
- sit = {
- { id = "http://www.roblox.com/asset/?id=393915321", weight = 10 }
- },
- toolnone = {
- { id = "http://www.roblox.com/asset/?id=393915542", weight = 10 }
- },
- toolslash = {
- { id = "http://www.roblox.com/asset/?id=393915542", weight = 10 }
- -- { id = "slash.xml", weight = 10 }
- },
- toollunge = {
- { id = "http://www.roblox.com/asset/?id=393915542", weight = 10 }
- },
- wave = {
- { id = "http://www.roblox.com/asset/?id=393915710", weight = 10 }
- },
- point = {
- { id = "http://www.roblox.com/asset/?id=393915866", weight = 10 }
- },
- dance = {
- { id = "http://www.roblox.com/asset/?id=393916260", weight = 10 },
- { id = "http://www.roblox.com/asset/?id=393916456", weight = 10 },
- { id = "http://www.roblox.com/asset/?id=393916635", weight = 10 }
- },
- dance2 = {
- { id = "http://www.roblox.com/asset/?id=393916791", weight = 10 },
- { id = "http://www.roblox.com/asset/?id=393916989", weight = 10 },
- { id = "http://www.roblox.com/asset/?id=393917195", weight = 10 }
- },
- dance3 = {
- { id = "http://www.roblox.com/asset/?id=393917375", weight = 10 },
- { id = "http://www.roblox.com/asset/?id=393917556", weight = 10 },
- { id = "http://www.roblox.com/asset/?id=393917721", weight = 10 }
- },
- laugh = {
- { id = "http://www.roblox.com/asset/?id=393916166", weight = 10 }
- },
- cheer = {
- { id = "http://www.roblox.com/asset/?id=393916016", weight = 10 }
- },
- }
- -- Existance in this list signifies that it is an emote, the value indicates if it is a looping emote
- local emoteNames = { wave = false, point = false, dance = true, dance2 = true, dance3 = true, laugh = false, cheer = false}
- math.randomseed(tick())
- function configureAnimationSet(name, fileList)
- if (animTable[name] ~= nil) then
- for _, connection in pairs(animTable[name].connections) do
- connection:disconnect()
- end
- end
- animTable[name] = {}
- animTable[name].count = 0
- animTable[name].totalWeight = 0
- animTable[name].connections = {}
- -- check for config values
- local config = script:FindFirstChild(name)
- if (config ~= nil) then
- -- print("Loading anims " .. name)
- table.insert(animTable[name].connections, config.ChildAdded:connect(function(child) configureAnimationSet(name, fileList) end))
- table.insert(animTable[name].connections, config.ChildRemoved:connect(function(child) configureAnimationSet(name, fileList) end))
- local idx = 1
- for _, childPart in pairs(config:GetChildren()) do
- if (childPart:IsA("Animation")) then
- table.insert(animTable[name].connections, childPart.Changed:connect(function(property) configureAnimationSet(name, fileList) end))
- animTable[name][idx] = {}
- animTable[name][idx].anim = childPart
- local weightObject = childPart:FindFirstChild("Weight")
- if (weightObject == nil) then
- animTable[name][idx].weight = 1
- else
- animTable[name][idx].weight = weightObject.Value
- end
- animTable[name].count = animTable[name].count + 1
- animTable[name].totalWeight = animTable[name].totalWeight + animTable[name][idx].weight
- -- print(name .. " [" .. idx .. "] " .. animTable[name][idx].anim.AnimationId .. " (" .. animTable[name][idx].weight .. ")")
- idx = idx + 1
- end
- end
- end
- -- fallback to defaults
- if (animTable[name].count <= 0) then
- for idx, anim in pairs(fileList) do
- animTable[name][idx] = {}
- animTable[name][idx].anim = Instance.new("Animation")
- animTable[name][idx].anim.Name = name
- animTable[name][idx].anim.AnimationId = anim.id
- animTable[name][idx].weight = anim.weight
- animTable[name].count = animTable[name].count + 1
- animTable[name].totalWeight = animTable[name].totalWeight + anim.weight
- -- print(name .. " [" .. idx .. "] " .. anim.id .. " (" .. anim.weight .. ")")
- end
- end
- end
- -- Setup animation objects
- function scriptChildModified(child)
- local fileList = animNames[child.Name]
- if (fileList ~= nil) then
- configureAnimationSet(child.Name, fileList)
- end
- end
- script.ChildAdded:connect(scriptChildModified)
- script.ChildRemoved:connect(scriptChildModified)
- for name, fileList in pairs(animNames) do
- configureAnimationSet(name, fileList)
- end
- -- ANIMATION
- -- declarations
- local toolAnim = "None"
- local toolAnimTime = 0
- local jumpAnimTime = 0
- local jumpAnimDuration = 0.31
- local toolTransitionTime = 0.1
- local fallTransitionTime = 0.2
- -- functions
- function stopAllAnimations()
- local oldAnim = currentAnim
- -- return to idle if finishing an emote
- if (emoteNames[oldAnim] ~= nil and emoteNames[oldAnim] == false) then
- oldAnim = "idle"
- end
- currentAnim = ""
- currentAnimInstance = nil
- if (currentAnimKeyframeHandler ~= nil) then
- currentAnimKeyframeHandler:disconnect()
- end
- if (currentAnimTrack ~= nil) then
- currentAnimTrack:Stop()
- currentAnimTrack:Destroy()
- currentAnimTrack = nil
- end
- return oldAnim
- end
- function setAnimationSpeed(speed)
- if speed ~= currentAnimSpeed then
- currentAnimSpeed = speed
- currentAnimTrack:AdjustSpeed(currentAnimSpeed)
- end
- end
- function keyFrameReachedFunc(frameName)
- if (frameName == "End") then
- -- print("Keyframe : ".. frameName)
- local repeatAnim = currentAnim
- -- return to idle if finishing an emote
- if (emoteNames[repeatAnim] ~= nil and emoteNames[repeatAnim] == false) then
- repeatAnim = "idle"
- end
- local animSpeed = currentAnimSpeed
- playAnimation(repeatAnim, 0.15, Humanoid)
- setAnimationSpeed(animSpeed)
- end
- end
- -- Preload animations
- function playAnimation(animName, transitionTime, humanoid)
- local roll = math.random(1, animTable[animName].totalWeight)
- local origRoll = roll
- local idx = 1
- while (roll > animTable[animName][idx].weight) do
- roll = roll - animTable[animName][idx].weight
- idx = idx + 1
- end
- -- print(animName .. " " .. idx .. " [" .. origRoll .. "]")
- local anim = animTable[animName][idx].anim
- -- switch animation
- if (anim ~= currentAnimInstance) then
- if (currentAnimTrack ~= nil) then
- currentAnimTrack:Stop(transitionTime)
- currentAnimTrack:Destroy()
- end
- currentAnimSpeed = 1.0
- -- load it to the humanoid; get AnimationTrack
- currentAnimTrack = humanoid:LoadAnimation(anim)
- -- play the animation
- currentAnimTrack:Play(transitionTime)
- currentAnim = animName
- currentAnimInstance = anim
- -- set up keyframe name triggers
- if (currentAnimKeyframeHandler ~= nil) then
- currentAnimKeyframeHandler:disconnect()
- end
- currentAnimKeyframeHandler = currentAnimTrack.KeyframeReached:connect(keyFrameReachedFunc)
- end
- end
- -------------------------------------------------------------------------------------------
- -------------------------------------------------------------------------------------------
- local toolAnimName = ""
- local toolAnimTrack = nil
- local toolAnimInstance = nil
- local currentToolAnimKeyframeHandler = nil
- function toolKeyFrameReachedFunc(frameName)
- if (frameName == "End") then
- -- print("Keyframe : ".. frameName)
- playToolAnimation(toolAnimName, 0.0, Humanoid)
- end
- end
- function playToolAnimation(animName, transitionTime, humanoid)
- local roll = math.random(1, animTable[animName].totalWeight)
- local origRoll = roll
- local idx = 1
- while (roll > animTable[animName][idx].weight) do
- roll = roll - animTable[animName][idx].weight
- idx = idx + 1
- end
- -- print(animName .. " * " .. idx .. " [" .. origRoll .. "]")
- local anim = animTable[animName][idx].anim
- if (toolAnimInstance ~= anim) then
- if (toolAnimTrack ~= nil) then
- toolAnimTrack:Stop()
- toolAnimTrack:Destroy()
- transitionTime = 0
- end
- -- load it to the humanoid; get AnimationTrack
- toolAnimTrack = humanoid:LoadAnimation(anim)
- -- play the animation
- toolAnimTrack:Play(transitionTime)
- toolAnimName = animName
- toolAnimInstance = anim
- currentToolAnimKeyframeHandler = toolAnimTrack.KeyframeReached:connect(toolKeyFrameReachedFunc)
- end
- end
- function stopToolAnimations()
- local oldAnim = toolAnimName
- if (currentToolAnimKeyframeHandler ~= nil) then
- currentToolAnimKeyframeHandler:disconnect()
- end
- toolAnimName = ""
- toolAnimInstance = nil
- if (toolAnimTrack ~= nil) then
- toolAnimTrack:Stop()
- toolAnimTrack:Destroy()
- toolAnimTrack = nil
- end
- return oldAnim
- end
- -------------------------------------------------------------------------------------------
- -------------------------------------------------------------------------------------------
- function onRunning(speed)
- if speed>0.01 then
- local scale = 15.0
- playAnimation("walk", 0.1, Humanoid)
- setAnimationSpeed(speed / scale)
- pose = "Running"
- else
- playAnimation("idle", 0.1, Humanoid)
- pose = "Standing"
- end
- end
- function onDied()
- pose = "Dead"
- end
- function onJumping()
- playAnimation("jump", 0.1, Humanoid)
- jumpAnimTime = jumpAnimDuration
- pose = "Jumping"
- end
- function onClimbing(speed)
- local scale = 2.0
- playAnimation("climb", 0.1, Humanoid)
- setAnimationSpeed(speed / scale)
- pose = "Climbing"
- end
- function onGettingUp()
- pose = "GettingUp"
- end
- function onFreeFall()
- if (jumpAnimTime <= 0) then
- playAnimation("fall", fallTransitionTime, Humanoid)
- end
- pose = "FreeFall"
- end
- function onFallingDown()
- pose = "FallingDown"
- end
- function onSeated()
- pose = "Seated"
- end
- function onPlatformStanding()
- pose = "PlatformStanding"
- end
- function onSwimming(speed)
- if speed>0 then
- pose = "Running"
- else
- pose = "Standing"
- end
- end
- function getTool()
- for _, kid in ipairs(Figure:GetChildren()) do
- if kid.className == "Tool" then return kid end
- end
- return nil
- end
- function getToolAnim(tool)
- for _, c in ipairs(tool:GetChildren()) do
- if c.Name == "toolanim" and c.className == "StringValue" then
- return c
- end
- end
- return nil
- end
- function animateTool()
- if (toolAnim == "None") then
- playToolAnimation("toolnone", toolTransitionTime, Humanoid)
- return
- end
- if (toolAnim == "Slash") then
- playToolAnimation("toolslash", 0, Humanoid)
- return
- end
- if (toolAnim == "Lunge") then
- playToolAnimation("toollunge", 0, Humanoid)
- return
- end
- end
- function moveSit()
- RightShoulder.MaxVelocity = 0.15
- LeftShoulder.MaxVelocity = 0.15
- RightShoulder:SetDesiredAngle(3.14 /2)
- LeftShoulder:SetDesiredAngle(-3.14 /2)
- RightHip:SetDesiredAngle(3.14 /2)
- LeftHip:SetDesiredAngle(-3.14 /2)
- end
- local lastTick = 0
- function move(time)
- local amplitude = 1
- local frequency = 1
- local deltaTime = time - lastTick
- lastTick = time
- local climbFudge = 0
- local setAngles = false
- if (jumpAnimTime > 0) then
- jumpAnimTime = jumpAnimTime - deltaTime
- end
- if (pose == "FreeFall" and jumpAnimTime <= 0) then
- playAnimation("fall", fallTransitionTime, Humanoid)
- elseif (pose == "Seated") then
- playAnimation("sit", 0.5, Humanoid)
- return
- elseif (pose == "Running") then
- playAnimation("walk", 0.1, Humanoid)
- elseif (pose == "Dead" or pose == "GettingUp" or pose == "FallingDown" or pose == "Seated" or pose == "PlatformStanding") then
- stopAllAnimations()
- amplitude = 0.1
- frequency = 1
- setAngles = true
- end
- -- Tool Animation handling
- local tool = getTool()
- if tool then
- animStringValueObject = getToolAnim(tool)
- if animStringValueObject then
- toolAnim = animStringValueObject.Value
- -- message recieved, delete StringValue
- animStringValueObject.Parent = nil
- toolAnimTime = time + .3
- end
- if time > toolAnimTime then
- toolAnimTime = 0
- toolAnim = "None"
- end
- animateTool()
- else
- stopToolAnimations()
- toolAnim = "None"
- toolAnimInstance = nil
- toolAnimTime = 0
- end
- end
- -- connect events
- Humanoid.Died:connect(onDied)
- Humanoid.Running:connect(onRunning)
- Humanoid.Jumping:connect(onJumping)
- Humanoid.Climbing:connect(onClimbing)
- Humanoid.GettingUp:connect(onGettingUp)
- Humanoid.FreeFalling:connect(onFreeFall)
- Humanoid.FallingDown:connect(onFallingDown)
- Humanoid.Seated:connect(onSeated)
- Humanoid.PlatformStanding:connect(onPlatformStanding)
- Humanoid.Swimming:connect(onSwimming)
- -- setup emote chat hook
- Game.Players.LocalPlayer.Chatted:connect(function(msg)
- local emote = ""
- if (string.sub(msg, 1, 3) == "/e ") then
- emote = string.sub(msg, 4)
- elseif (string.sub(msg, 1, 7) == "/emote ") then
- emote = string.sub(msg, 8)
- end
- if (pose == "Standing" and emoteNames[emote] ~= nil) then
- playAnimation(emote, 0.1, Humanoid)
- end
- -- print("===> " .. string.sub(msg, 1, 3) .. "(" .. emote .. ")")
- end)
- -- main program
- local runService = game:service("RunService");
- -- print("bottom")
- -- initialize to idle
- playAnimation("idle", 0.1, Humanoid)
- pose = "Standing"
- while Figure.Parent~=nil do
- local _, time = wait(0.1)
- move(time)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement