Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local g = getgenv and getgenv() or _G
- do
- -- Settings:
- local DefaultAnimations = true
- local DisableCharacterCollisions = true
- local InstantRespawn = true
- local ParentCharacterToRig = true
- local RigTransparency = 1
- -- Circle Movement Settings
- local CircleRadius = g.CircleRadius
- local CircleSpeed = g.CircleSpeed
- local LimbFloatHeight = g.LimbFloatHeight
- --
- local CFrameidentity = CFrame.identity
- local Inverse = CFrameidentity.Inverse
- local ToAxisAngle = CFrameidentity.ToAxisAngle
- local ToEulerAnglesXYZ = CFrameidentity.ToEulerAnglesXYZ
- local ToObjectSpace = CFrameidentity.ToObjectSpace
- local Connections = {}
- local Disconnect = nil
- local game = game
- local FindFirstChild = game.FindFirstChild
- local FindFirstChildOfClass = game.FindFirstChildOfClass
- local Players = FindFirstChildOfClass(game, "Players")
- local LocalPlayer = Players.LocalPlayer
- local Character = LocalPlayer.Character
- local CharacterAdded = LocalPlayer.CharacterAdded
- local Connect = CharacterAdded.Connect
- local Wait = CharacterAdded.Wait
- local Rig = Players:CreateHumanoidModelFromDescription(Players:GetHumanoidDescriptionFromUserId(LocalPlayer.UserId), Enum.HumanoidRigType.R6)
- local RigAnimate = Rig.Animate
- local RigHumanoid = Rig.Humanoid
- local RigRootPart = RigHumanoid.RootPart
- local RunService = FindFirstChildOfClass(game, "RunService")
- local Workspace = FindFirstChildOfClass(game, "Workspace")
- local GetDescendants = game.GetDescendants
- local IsA = game.IsA
- local WaitForChild = game.WaitForChild
- local BreakJoints = Instance.new("Model").BreakJoints
- local mathsin = math.sin
- local mathcos = math.cos
- local mathrad = math.rad
- local next = next
- local osclock = os.clock
- local replicatesignal = replicatesignal
- local RootPartCFrame = nil
- local Motor6Ds = {}
- local LimbMotors = {}
- local select = select
- local sethiddenproperty = sethiddenproperty
- local tableinsert = table.insert
- local Vector3 = Vector3
- local Vector3new = Vector3.new
- local Vector3zero = Vector3.zero
- local CFramenew = CFrame.new
- local CFrameAngles = CFrame.Angles
- RigAnimate.Enabled = false
- Rig.Name = LocalPlayer.Name
- RigHumanoid.DisplayName = LocalPlayer.DisplayName
- if Character then
- if replicatesignal then
- if InstantRespawn then
- replicatesignal(LocalPlayer.ConnectDiedSignalBackend)
- task.wait(Players.RespawnTime - 0.1)
- local RootPart = FindFirstChild(Character, "HumanoidRootPart")
- if RootPart then
- RootPartCFrame = RootPart.CFrame
- end
- replicatesignal(LocalPlayer.Kill)
- end
- else
- BreakJoints(Character)
- end
- end
- Character = Wait(CharacterAdded)
- local Animate = WaitForChild(Character, "Animate")
- Animate.Enabled = false
- local RootPart = WaitForChild(Character, "HumanoidRootPart")
- RigRootPart.CFrame = RootPartCFrame or RootPart.CFrame
- -- Store references to character limbs
- local CharLeftArm = FindFirstChild(Character, "Left Arm")
- local CharRightArm = FindFirstChild(Character, "Right Arm")
- local CharLeftLeg = FindFirstChild(Character, "Left Leg")
- local CharRightLeg = FindFirstChild(Character, "Right Leg")
- Disconnect = Connect(RigHumanoid.Died, function()
- for Index, Connection in Connections do
- Disconnect(Connection)
- end
- if ParentCharacterToRig then
- Character.Parent = Rig.Parent
- end
- BreakJoints(Character)
- Rig:Destroy()
- end).Disconnect
- -- Identify limb motors
- for Index, Descendant in next, GetDescendants(Character) do
- if IsA(Descendant, "Motor6D") then
- local rigPart0 = FindFirstChild(Rig, Descendant.Part0.Name)
- local rigPart1 = FindFirstChild(Rig, Descendant.Part1.Name)
- if rigPart0 and rigPart1 then
- Motor6Ds[Descendant] = {
- Part0 = rigPart0,
- Part1 = rigPart1
- }
- -- Check if this motor controls a limb
- local part1Name = Descendant.Part1.Name
- if part1Name == "Left Arm" or part1Name == "Right Arm" or part1Name == "Left Leg" or part1Name == "Right Leg" then
- LimbMotors[Descendant] = true
- end
- end
- end
- end
- for Index, Descendant in next, GetDescendants(Rig) do
- if IsA(Descendant, "BasePart") then
- Descendant.Transparency = RigTransparency
- end
- end
- Rig.Parent = Workspace
- if ParentCharacterToRig then
- Character.Parent = Rig
- end
- task.defer(function()
- local CurrentCamera = Workspace.CurrentCamera
- local CameraCFrame = CurrentCamera.CFrame
- LocalPlayer.Character = Rig
- CurrentCamera.CameraSubject = RigHumanoid
- Wait(RunService.PreRender)
- Workspace.CurrentCamera.CFrame = CameraCFrame
- end)
- tableinsert(Connections, Connect(RunService.PostSimulation, function()
- local currentTime = osclock()
- for Motor6D, Table in next, Motor6Ds do
- local Part0 = Table.Part0
- local Part1 = Table.Part1
- if LimbMotors[Motor6D] then
- -- Handle limb motors with circular movement
- local angleOffset = 0
- local limbName = Part1.Name
- if limbName == "Left Arm" then angleOffset = 0
- elseif limbName == "Right Arm" then angleOffset = 90
- elseif limbName == "Left Leg" then angleOffset = 180
- elseif limbName == "Right Leg" then angleOffset = 270
- end
- local angle = mathrad(angleOffset + currentTime * CircleSpeed * 50)
- local x = mathcos(angle) * CircleRadius
- local z = mathsin(angle) * CircleRadius
- local y = mathsin(currentTime * 3 + angleOffset * 0.1) * LimbFloatHeight
- -- Get corresponding character limb
- local charLimb = FindFirstChild(Character, limbName)
- if charLimb then
- -- Calculate desired position relative to torso
- local offset = Vector3new(x, y, z)
- local desiredCFrame = CFramenew(RigRootPart.Position + offset) * CFrameAngles(
- mathsin(currentTime * 2 + angleOffset * 0.05) * 0.5,
- angle,
- mathcos(currentTime * 1.5 + angleOffset * 0.05) * 0.3
- )
- -- Update character limb to match
- charLimb.CFrame = desiredCFrame
- -- Calculate motor6D properties
- Motor6D.DesiredAngle = select(3, ToEulerAnglesXYZ(desiredCFrame, Part0.CFrame))
- local Delta = Inverse(Motor6D.C0) * (Inverse(Part0.CFrame) * desiredCFrame) * Motor6D.C1
- local Axis, Angle = ToAxisAngle(Delta)
- sethiddenproperty(Motor6D, "ReplicateCurrentAngle6D", Axis * Angle)
- sethiddenproperty(Motor6D, "ReplicateCurrentOffset6D", Delta.Position)
- end
- else
- -- Normal motor6D handling for non-limb parts
- local Part1CFrame = Table.Part1.CFrame
- Motor6D.DesiredAngle = select(3, ToEulerAnglesXYZ(Part1CFrame, Part0.CFrame))
- local Delta = Inverse(Motor6D.C0) * (Inverse(Part0.CFrame) * Part1CFrame) * Motor6D.C1
- local Axis, Angle = ToAxisAngle(Delta)
- sethiddenproperty(Motor6D, "ReplicateCurrentAngle6D", Axis * Angle)
- sethiddenproperty(Motor6D, "ReplicateCurrentOffset6D", Delta.Position)
- end
- end
- RootPart.AssemblyAngularVelocity = Vector3zero
- RootPart.AssemblyLinearVelocity = Vector3zero
- RootPart.CFrame = RigRootPart.CFrame + Vector3new(0, mathsin(currentTime * 15) * 0.004, 0)
- end))
- tableinsert(Connections, Connect(RunService.PreSimulation, function()
- for Index, BasePart in next, GetDescendants(Rig) do
- if IsA(BasePart, "BasePart") then
- BasePart.CanCollide = false
- end
- end
- if DisableCharacterCollisions and not ParentCharacterToRig then
- for Index, BasePart in next, GetDescendants(Character) do
- if IsA(BasePart, "BasePart") then
- BasePart.CanCollide = false
- end
- end
- end
- end))
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement