local Players = game:GetService("Players") local RunService = game:GetService("RunService") local Workspace = game:GetService("Workspace") local TweenService = game:GetService("TweenService") local CoreGui = game:GetService("CoreGui") local HUB_NAME = "FE Amigo Enemigo ⚡👊" local player = Players.LocalPlayer if not player then for _ = 1, 80 do player = Players.LocalPlayer if player then break end task.wait(0.05) end end if not player then return end local function getUiParent() local okGui, guiRes = pcall(function() if typeof(gethui) == "function" then return gethui() end return nil end) if okGui and guiRes then return guiRes end local okCore, coreRes = pcall(function() return CoreGui end) if okCore and coreRes then return coreRes end return player:FindFirstChildOfClass("PlayerGui") or player:WaitForChild("PlayerGui", 5) end local playerGui = player:FindFirstChildOfClass("PlayerGui") or player:WaitForChild("PlayerGui", 5) local uiParent = getUiParent() or playerGui local character = player.Character local JOINT_KEYS = { "root", "waist", "neck", "lShoulder", "rShoulder", "lHip", "rHip" } local HIGH_FALL_STUDS = 28 local HUG_DISTANCE = 8 local PUNCH_RANGE = 8.5 local PUNCH_DAMAGE = 22 local LAUNCH_FORWARD_SPEED = 110 local LAUNCH_UP_SPEED = 85 local savedTransforms = {} local currentPoseTargets = {} local animateScript = nil local previousAnimateEnabled = nil local ragdollApplied = false local fallRagdollTriggered = false local dustEmitter = nil local dustAttachment = nil local currentRigType = Enum.HumanoidRigType.R15 local joints = {} local actionBar = nil local hugButton = nil local launchButton = nil local punchButton = nil local actionBarVisible = false local actionBarTween = nil local isHugging = false local hugTimer = 0 local isPunching = false local punchTimer = 0 local punchCooldown = 0 local punchHitApplied = false local nearestTargetRoot = nil local savedWalkSpeed = nil local savedJumpPower = nil local savedJumpHeight = nil local savedUseJumpPower = nil local function createLoadingScreen() local host = playerGui or uiParent if not host then return function() end, function() end end pcall(function() local oldGui = host:FindFirstChild("FE_LoaderGui") if oldGui then oldGui:Destroy() end end) local screenGui = Instance.new("ScreenGui") screenGui.Name = "FE_LoaderGui" screenGui.Enabled = true screenGui.ResetOnSpawn = false screenGui.DisplayOrder = 999 screenGui.Parent = host local bgFrame = Instance.new("Frame") bgFrame.Name = "GradientBackdrop" bgFrame.Size = UDim2.fromScale(1, 1) bgFrame.BackgroundColor3 = Color3.fromRGB(35, 35, 35) bgFrame.BackgroundTransparency = 0.25 bgFrame.BorderSizePixel = 0 bgFrame.Parent = screenGui local card = Instance.new("Frame") card.Name = "LoaderCard" card.AnchorPoint = Vector2.new(0.5, 0.5) card.Position = UDim2.fromScale(0.5, 0.5) card.Size = UDim2.fromOffset(370, 126) card.BackgroundColor3 = Color3.fromRGB(25, 25, 25) card.BackgroundTransparency = 0.25 card.BorderSizePixel = 0 card.Parent = bgFrame local corner = Instance.new("UICorner") corner.CornerRadius = UDim.new(0, 12) corner.Parent = card local titleLabel = Instance.new("TextLabel") titleLabel.Name = "TitleLabel" titleLabel.Size = UDim2.new(1, -24, 0, 32) titleLabel.Position = UDim2.fromOffset(12, 14) titleLabel.BackgroundTransparency = 1 titleLabel.Font = Enum.Font.GothamBold titleLabel.TextSize = 18 titleLabel.TextColor3 = Color3.fromRGB(245, 245, 245) titleLabel.Text = "Cargando " .. HUB_NAME .. "..." titleLabel.Parent = card local statusLabel = Instance.new("TextLabel") statusLabel.Name = "StatusLabel" statusLabel.Size = UDim2.new(1, -24, 0, 48) statusLabel.Position = UDim2.fromOffset(12, 54) statusLabel.BackgroundTransparency = 1 statusLabel.Font = Enum.Font.Gotham statusLabel.TextSize = 14 statusLabel.TextWrapped = true statusLabel.TextColor3 = Color3.fromRGB(215, 215, 215) statusLabel.Text = "Preparando funciones..." statusLabel.Parent = card local function setStatus(msg) pcall(function() if statusLabel and statusLabel.Parent then statusLabel.Text = msg end end) task.wait(0.15) end local function dismiss() task.wait(0.25) pcall(function() if not screenGui or not screenGui.Parent then return end local fadeOut = TweenService:Create(bgFrame, TweenInfo.new(0.35, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), { BackgroundTransparency = 1, }) for _, desc in ipairs(bgFrame:GetDescendants()) do if desc:IsA("TextLabel") then TweenService:Create(desc, TweenInfo.new(0.35), { TextTransparency = 1 }):Play() elseif desc:IsA("Frame") then TweenService:Create(desc, TweenInfo.new(0.35), { BackgroundTransparency = 1 }):Play() end end fadeOut:Play() fadeOut.Completed:Once(function() if screenGui and screenGui.Parent then screenGui:Destroy() end end) end) end return setStatus, dismiss end local setLoaderStatus, dismissLoader = createLoadingScreen() setLoaderStatus("Iniciando " .. HUB_NAME .. "...") local function setActionBarVisible(visible) if not actionBar or not actionBar.Parent then return end if actionBarVisible == visible then return end actionBarVisible = visible if actionBarTween then actionBarTween:Cancel() actionBarTween = nil end local targetPos = visible and UDim2.new(0.5, 0, 0.82, 0) or UDim2.new(0.5, 0, 1.18, 0) local style = visible and Enum.EasingStyle.Back or Enum.EasingStyle.Quad local direction = visible and Enum.EasingDirection.Out or Enum.EasingDirection.In actionBarTween = TweenService:Create(actionBar, TweenInfo.new(0.25, style, direction), { Position = targetPos, }) actionBarTween:Play() end local function findJumpButton() local containers = {} if playerGui then table.insert(containers, playerGui) end if uiParent and uiParent ~= playerGui then table.insert(containers, uiParent) end for _, root in ipairs(containers) do for _, obj in ipairs(root:GetDescendants()) do if obj:IsA("GuiButton") and obj.Name ~= "FE_PunchJumpBtn" then local lowerName = string.lower(obj.Name) if lowerName == "jumpbutton" or string.find(lowerName, "jump", 1, true) then return obj end end end end return nil end local function createPunchButtonNextToJump() local host = playerGui or uiParent if not host then return end local oldGui = host:FindFirstChild("FE_PunchJumpGui") if oldGui then oldGui:Destroy() end local jumpBtn = findJumpButton() local sg = Instance.new("ScreenGui") sg.Name = "FE_PunchJumpGui" sg.Enabled = true sg.ResetOnSpawn = false sg.DisplayOrder = 45 sg.Parent = host local btn = Instance.new("ImageButton") btn.Name = "FE_PunchJumpBtn" btn.BorderSizePixel = 0 btn.AutoButtonColor = true btn.Parent = sg local corner = Instance.new("UICorner") corner.CornerRadius = UDim.new(1, 0) corner.Parent = btn local iconLabel = Instance.new("TextLabel") iconLabel.Name = "PunchIcon" iconLabel.Size = UDim2.fromScale(0.65, 0.65) iconLabel.AnchorPoint = Vector2.new(0.5, 0.5) iconLabel.Position = UDim2.fromScale(0.5, 0.5) iconLabel.BackgroundTransparency = 1 iconLabel.Font = Enum.Font.GothamBold iconLabel.TextScaled = true iconLabel.TextColor3 = Color3.fromRGB(255, 255, 255) iconLabel.Text = "👊" iconLabel.Parent = btn if jumpBtn and jumpBtn.AbsolutePosition.X > 0 and jumpBtn.AbsolutePosition.Y > 0 then local sizePx = math.clamp(jumpBtn.AbsoluteSize.X > 0 and jumpBtn.AbsoluteSize.X or 68, 48, 96) btn.Size = UDim2.fromOffset(sizePx, sizePx) btn.AnchorPoint = Vector2.new(0, 0) btn.Position = UDim2.fromOffset(jumpBtn.AbsolutePosition.X - sizePx - 12, jumpBtn.AbsolutePosition.Y) btn.BackgroundColor3 = jumpBtn.BackgroundColor3 btn.BackgroundTransparency = jumpBtn.BackgroundTransparency else btn.Size = UDim2.fromOffset(68, 68) btn.AnchorPoint = Vector2.new(1, 1) btn.Position = UDim2.new(1, -108, 1, -28) btn.BackgroundColor3 = Color3.fromRGB(35, 35, 35) btn.BackgroundTransparency = 0.2 end punchButton = btn end local function createActionButtons() local host = playerGui or uiParent if not host then return end local oldGui = host:FindFirstChild("FE_HugGui") if oldGui then oldGui:Destroy() end local screenGui = Instance.new("ScreenGui") screenGui.Name = "FE_HugGui" screenGui.Enabled = true screenGui.ResetOnSpawn = false screenGui.DisplayOrder = 40 screenGui.Parent = host local bar = Instance.new("Frame") bar.Name = "ActionBar" bar.AnchorPoint = Vector2.new(0.5, 0.5) bar.Position = UDim2.new(0.5, 0, 1.18, 0) bar.Size = UDim2.fromOffset(312, 48) bar.BackgroundTransparency = 1 bar.BorderSizePixel = 0 bar.Parent = screenGui local layout = Instance.new("UIListLayout") layout.FillDirection = Enum.FillDirection.Horizontal layout.HorizontalAlignment = Enum.HorizontalAlignment.Center layout.VerticalAlignment = Enum.VerticalAlignment.Center layout.Padding = UDim.new(0, 12) layout.Parent = bar local hugBtn = Instance.new("TextButton") hugBtn.Name = "HugButton" hugBtn.Size = UDim2.fromOffset(146, 46) hugBtn.BackgroundColor3 = Color3.fromRGB(35, 35, 35) hugBtn.BackgroundTransparency = 0.15 hugBtn.BorderSizePixel = 0 hugBtn.Font = Enum.Font.GothamBold hugBtn.TextSize = 16 hugBtn.TextColor3 = Color3.fromRGB(245, 245, 245) hugBtn.Text = "Abrazar" hugBtn.Parent = bar local hugCorner = Instance.new("UICorner") hugCorner.CornerRadius = UDim.new(0, 12) hugCorner.Parent = hugBtn local launchBtn = Instance.new("TextButton") launchBtn.Name = "LaunchButton" launchBtn.Size = UDim2.fromOffset(146, 46) launchBtn.BackgroundColor3 = Color3.fromRGB(58, 32, 32) launchBtn.BackgroundTransparency = 0.15 launchBtn.BorderSizePixel = 0 launchBtn.Font = Enum.Font.GothamBold launchBtn.TextSize = 16 launchBtn.TextColor3 = Color3.fromRGB(250, 235, 235) launchBtn.Text = "Lanzar" launchBtn.Parent = bar local launchCorner = Instance.new("UICorner") launchCorner.CornerRadius = UDim.new(0, 12) launchCorner.Parent = launchBtn actionBar = bar hugButton = hugBtn launchButton = launchBtn actionBarVisible = false createPunchButtonNextToJump() end pcall(createActionButtons) local soundParent = playerGui or uiParent or Workspace for _, name in ipairs({ "FE_StepSound", "FE_FallImpactSound", "FE_DieSound", "FE_PunchSound" }) do local old = soundParent:FindFirstChild(name) if old then old:Destroy() end end local stepSound = Instance.new("Sound") stepSound.Name = "FE_StepSound" stepSound.SoundId = "rbxasset://sounds/action_footsteps_plastic.mp3" stepSound.Looped = false stepSound.Volume = 1 stepSound.Parent = soundParent local fallImpactSound = Instance.new("Sound") fallImpactSound.Name = "FE_FallImpactSound" fallImpactSound.SoundId = "rbxasset://sounds/action_falling.mp3" fallImpactSound.PlaybackSpeed = 0.85 fallImpactSound.Volume = 0.9 fallImpactSound.Parent = soundParent local dieSound = Instance.new("Sound") dieSound.Name = "FE_DieSound" dieSound.SoundId = "rbxasset://sounds/uuhhh.mp3" dieSound.Volume = 0.85 dieSound.Parent = soundParent local punchSound = Instance.new("Sound") punchSound.Name = "FE_PunchSound" punchSound.SoundId = "rbxasset://sounds/impact_generic.mp3" punchSound.PlaybackSpeed = 1.15 punchSound.Volume = 0.95 punchSound.Parent = soundParent local function detectRigType(char) local hum = char and char:FindFirstChildOfClass("Humanoid") if hum and hum.RigType == Enum.HumanoidRigType.R6 then return Enum.HumanoidRigType.R6 end if char and char:FindFirstChild("Torso") and not char:FindFirstChild("UpperTorso") then return Enum.HumanoidRigType.R6 end return Enum.HumanoidRigType.R15 end local function getJoints(char, rigType) if not char then return {} end if rigType == Enum.HumanoidRigType.R6 then local torso = char:FindFirstChild("Torso") local hrp = char:FindFirstChild("HumanoidRootPart") return { root = hrp and hrp:FindFirstChild("RootJoint"), waist = nil, neck = torso and torso:FindFirstChild("Neck"), lShoulder = torso and torso:FindFirstChild("Left Shoulder"), rShoulder = torso and torso:FindFirstChild("Right Shoulder"), lHip = torso and torso:FindFirstChild("Left Hip"), rHip = torso and torso:FindFirstChild("Right Hip"), } end return { root = char:FindFirstChild("RootJoint", true), waist = char:FindFirstChild("Waist", true), neck = char:FindFirstChild("Neck", true), lShoulder = char:FindFirstChild("LeftShoulder", true), rShoulder = char:FindFirstChild("RightShoulder", true), lHip = char:FindFirstChild("LeftHip", true), rHip = char:FindFirstChild("RightHip", true), } end local function setMovementLocked(char, locked) local hum = char and char:FindFirstChildOfClass("Humanoid") local hrp = char and char:FindFirstChild("HumanoidRootPart") if not hum then return end if locked then if savedWalkSpeed == nil then savedWalkSpeed = hum.WalkSpeed end if savedUseJumpPower == nil then savedUseJumpPower = hum.UseJumpPower end if savedJumpPower == nil then savedJumpPower = hum.JumpPower end if savedJumpHeight == nil then savedJumpHeight = hum.JumpHeight end hum.WalkSpeed = 0 if hum.UseJumpPower then hum.JumpPower = 0 else hum.JumpHeight = 0 end if hrp then hrp.AssemblyLinearVelocity = Vector3.new(0, math.min(hrp.AssemblyLinearVelocity.Y, 0), 0) hrp.AssemblyAngularVelocity = Vector3.zero end else if savedWalkSpeed ~= nil then hum.WalkSpeed = savedWalkSpeed; savedWalkSpeed = nil end if savedUseJumpPower ~= nil then hum.UseJumpPower = savedUseJumpPower; savedUseJumpPower = nil end if savedJumpPower ~= nil then hum.JumpPower = savedJumpPower; savedJumpPower = nil end if savedJumpHeight ~= nil then hum.JumpHeight = savedJumpHeight; savedJumpHeight = nil end end end local function setupDustParticleEffect(char) if dustEmitter then dustEmitter:Destroy(); dustEmitter = nil end if dustAttachment then dustAttachment:Destroy(); dustAttachment = nil end local hrp = char and char:FindFirstChild("HumanoidRootPart") if not hrp then return end local att = Instance.new("Attachment") att.Name = "FE_DustParticleAtt" att.Position = Vector3.new(0, -2.55, 0.25) att.Parent = hrp local emitter = Instance.new("ParticleEmitter") emitter.Name = "FE_FootstepDust" emitter.Texture = "rbxasset://textures/particles/smoke_main.dds" emitter.Color = ColorSequence.new({ ColorSequenceKeypoint.new(0, Color3.fromRGB(215, 208, 196)), ColorSequenceKeypoint.new(1, Color3.fromRGB(155, 148, 138)), }) emitter.Size = NumberSequence.new({ NumberSequenceKeypoint.new(0, 0.55), NumberSequenceKeypoint.new(0.45, 1.35), NumberSequenceKeypoint.new(1, 2.15), }) emitter.Transparency = NumberSequence.new({ NumberSequenceKeypoint.new(0, 0.28), NumberSequenceKeypoint.new(0.65, 0.58), NumberSequenceKeypoint.new(1, 1), }) emitter.Lifetime = NumberRange.new(0.55, 0.95) emitter.Rate = 0 emitter.Speed = NumberRange.new(1.5, 3.8) emitter.SpreadAngle = Vector2.new(75, 75) emitter.Acceleration = Vector3.new(0, 1.6, 0) emitter.Drag = 4 emitter.Rotation = NumberRange.new(0, 360) emitter.RotSpeed = NumberRange.new(-40, 40) emitter.LightEmission = 0 emitter.LightInfluence = 1 emitter.Parent = att dustAttachment = att dustEmitter = emitter end local function playCleanStep(isRunning) local basePitch = isRunning and 1.24 or 0.98 stepSound.PlaybackSpeed = basePitch + (math.random(-5, 5) / 100) stepSound.TimePosition = 0 stepSound:Play() end local function stopActiveTracks(char) local hum = char and char:FindFirstChildOfClass("Humanoid") local animator = hum and hum:FindFirstChildOfClass("Animator") if animator then for _, track in ipairs(animator:GetPlayingAnimationTracks()) do track:Stop(0) end end end local function setAnimatePaused(paused) local char = player.Character local anim = char and char:FindFirstChild("Animate") if anim then if paused then if animateScript ~= anim then animateScript = anim previousAnimateEnabled = anim.Enabled end pcall(function() anim.Enabled = false end) else if animateScript == anim and previousAnimateEnabled ~= nil then pcall(function() anim.Enabled = previousAnimateEnabled end) else pcall(function() anim.Enabled = true end) end animateScript = nil previousAnimateEnabled = nil end end if paused and char then stopActiveTracks(char) end end local function captureBaseTransforms() table.clear(savedTransforms) table.clear(currentPoseTargets) for _, key in ipairs(JOINT_KEYS) do local joint = joints[key] if joint and joint:IsA("Motor6D") then savedTransforms[key] = CFrame.identity currentPoseTargets[key] = CFrame.identity joint.Transform = CFrame.identity end end end local function restoreBaseTransforms() for _, key in ipairs(JOINT_KEYS) do local joint = joints[key] if joint and joint:IsA("Motor6D") then joint.Transform = CFrame.identity end end end local function setJointTarget(jointKey, cf) currentPoseTargets[jointKey] = cf end local function armForward(rigType, angleForward, sideSpread) return angleForward, 0, sideSpread end local function legForward(rigType, angleForward) return angleForward, 0, 0 end local function stepSmoothPose(dt, stiffness) local activeChar = player.Character if activeChar then stopActiveTracks(activeChar) end local alpha = 1 - math.exp(-(stiffness or 16) * dt) for _, key in ipairs(JOINT_KEYS) do if key ~= "neck" then local joint = joints[key] local desired = currentPoseTargets[key] or CFrame.identity if joint and joint:IsA("Motor6D") then joint.Transform = joint.Transform:Lerp(desired, alpha) end end end end local function applyRealDamageToNearby(myChar, myHrp) if not myHrp then return end local hitAny = false local function tryDamageModel(model) if not model or not model:IsA("Model") or model == myChar then return end local targetHum = model:FindFirstChildOfClass("Humanoid") local targetRoot = model:FindFirstChild("HumanoidRootPart") or model:FindFirstChild("Torso") or model:FindFirstChild("UpperTorso") if targetHum and targetRoot and targetHum.Health > 0 then local dist = (targetRoot.Position - myHrp.Position).Magnitude if dist <= PUNCH_RANGE then hitAny = true pcall(function() targetHum:TakeDamage(PUNCH_DAMAGE) end) if targetHum.Health > 0 then pcall(function() targetHum.Health = math.max(0, targetHum.Health - PUNCH_DAMAGE) end) end pcall(function() local knockDir = (targetRoot.Position - myHrp.Position) if knockDir.Magnitude > 0.01 then knockDir = Vector3.new(knockDir.X, 0, knockDir.Z).Unit else knockDir = myHrp.CFrame.LookVector end targetRoot:ApplyImpulse((knockDir * 45 + Vector3.new(0, 22, 0)) * targetRoot.AssemblyMass) end) end end end for _, plr in ipairs(Players:GetPlayers()) do if plr ~= player and plr.Character then tryDamageModel(plr.Character) end end for _, obj in ipairs(Workspace:GetChildren()) do tryDamageModel(obj) end if hitAny then punchSound.TimePosition = 0 punchSound:Play() end end local function triggerPunch() local char = player.Character local hrp = char and char:FindFirstChild("HumanoidRootPart") local hum = char and char:FindFirstChildOfClass("Humanoid") if not char or not hrp or not hum or hum.Health <= 0 or ragdollApplied then return end if punchCooldown > 0 or isPunching or isHugging then return end character = char currentRigType = detectRigType(char) joints = getJoints(char, currentRigType) setAnimatePaused(true) captureBaseTransforms() isPunching = true punchTimer = 0.42 punchCooldown = 0.55 punchHitApplied = false end local function triggerHug() local char = player.Character local hrp = char and char:FindFirstChild("HumanoidRootPart") local hum = char and char:FindFirstChildOfClass("Humanoid") if not char or not hrp or not hum or hum.Health <= 0 or ragdollApplied or isHugging then return end if nearestTargetRoot and nearestTargetRoot.Parent then local targetPos = nearestTargetRoot.Position local flatTarget = Vector3.new(targetPos.X, hrp.Position.Y, targetPos.Z) if (flatTarget - hrp.Position).Magnitude > 1.8 then local lookCFrame = CFrame.lookAt(hrp.Position, flatTarget) local closePos = flatTarget - (lookCFrame.LookVector * 2.1) hrp.CFrame = CFrame.lookAt(closePos, flatTarget) end end isPunching = false punchTimer = 0 character = char currentRigType = detectRigType(char) joints = getJoints(char, currentRigType) setAnimatePaused(true) captureBaseTransforms() isHugging = true hugTimer = 1.35 setMovementLocked(char, true) end local function triggerLaunch() local char = player.Character local hrp = char and char:FindFirstChild("HumanoidRootPart") local hum = char and char:FindFirstChildOfClass("Humanoid") if not char or not hrp or not hum or hum.Health <= 0 or ragdollApplied then return end local targetRoot = nearestTargetRoot if not targetRoot or not targetRoot.Parent then return end local targetModel = targetRoot:FindFirstAncestorOfClass("Model") local targetHum = targetModel and targetModel:FindFirstChildOfClass("Humanoid") local flatTarget = Vector3.new(targetRoot.Position.X, hrp.Position.Y, targetRoot.Position.Z) local dirVec = flatTarget - hrp.Position if dirVec.Magnitude > 0.01 then hrp.CFrame = CFrame.lookAt(hrp.Position, flatTarget) dirVec = dirVec.Unit else dirVec = hrp.CFrame.LookVector end local launchVel = (dirVec * LAUNCH_FORWARD_SPEED) + Vector3.new(0, LAUNCH_UP_SPEED, 0) pcall(function() if targetHum then targetHum.Sit = false targetHum.PlatformStand = false targetHum:ChangeState(Enum.HumanoidStateType.Jumping) end local oldBv = targetRoot:FindFirstChild("FE_LaunchVel") if oldBv then oldBv:Destroy() end local bv = Instance.new("BodyVelocity") bv.Name = "FE_LaunchVel" bv.MaxForce = Vector3.new(1e7, 1e7, 1e7) bv.Velocity = launchVel bv.Parent = targetRoot targetRoot:ApplyImpulse(launchVel * targetRoot.AssemblyMass) for _, part in ipairs(targetModel and targetModel:GetDescendants() or {}) do if part:IsA("BasePart") and not part.Anchored then part.AssemblyLinearVelocity = launchVel part.AssemblyAngularVelocity = Vector3.new(12, 16, 12) end end task.delay(0.18, function() if bv and bv.Parent then bv:Destroy() end end) end) end if hugButton then hugButton.MouseButton1Click:Connect(triggerHug) end if launchButton then launchButton.MouseButton1Click:Connect(triggerLaunch) end if punchButton then punchButton.MouseButton1Click:Connect(triggerPunch) end local function evaluateCandidateModel(model, myChar, myHrp, bestRoot, bestDist) if not model or not model:IsA("Model") or model == myChar then return bestRoot, bestDist end local hum = model:FindFirstChildOfClass("Humanoid") local root = model:FindFirstChild("HumanoidRootPart") if hum and root and hum.Health > 0 then local dist = (root.Position - myHrp.Position).Magnitude if dist <= bestDist then return root, dist end end return bestRoot, bestDist end local function findNearestPersonRoot(myChar, myHrp) if not myHrp then return nil end local bestRoot = nil local bestDist = HUG_DISTANCE for _, plr in ipairs(Players:GetPlayers()) do if plr ~= player and plr.Character then bestRoot, bestDist = evaluateCandidateModel(plr.Character, myChar, myHrp, bestRoot, bestDist) end end for _, obj in ipairs(Workspace:GetChildren()) do bestRoot, bestDist = evaluateCandidateModel(obj, myChar, myHrp, bestRoot, bestDist) end return bestRoot end local function applyCleanRagdoll(char, isDeath) if ragdollApplied or not char then return end ragdollApplied = true isHugging = false hugTimer = 0 isPunching = false punchTimer = 0 setMovementLocked(char, false) setActionBarVisible(false) setAnimatePaused(false) if dustEmitter then dustEmitter.Rate = 0 end local humanoid = char:FindFirstChildOfClass("Humanoid") if humanoid then humanoid.BreakJointsOnDeath = false humanoid:ChangeState(Enum.HumanoidStateType.Physics) humanoid.PlatformStand = true end for _, desc in ipairs(char:GetDescendants()) do if desc:IsA("Motor6D") then local part0 = desc.Part0 local part1 = desc.Part1 if part0 and part1 then local a0 = Instance.new("Attachment") a0.Name = "FE_RagdollA0" a0.CFrame = desc.C0 a0.Parent = part0 local a1 = Instance.new("Attachment") a1.Name = "FE_RagdollA1" a1.CFrame = desc.C1 a1.Parent = part1 local socket = Instance.new("BallSocketConstraint") socket.Name = "FE_RagdollSocket" socket.Attachment0 = a0 socket.Attachment1 = a1 socket.LimitsEnabled = true socket.TwistLimitsEnabled = true socket.Parent = part1 end desc.Enabled = false end end if isDeath then dieSound:Play() else fallImpactSound:Play() end end task.spawn(function() while true do local dt = task.wait() pcall(function() local char = player.Character local hum = char and char:FindFirstChildOfClass("Humanoid") local hrp = char and char:FindFirstChild("HumanoidRootPart") local cam = Workspace.CurrentCamera local neck = joints and joints.neck if char and hum and hrp and neck and neck:IsA("Motor6D") and neck.Enabled and hum.Health > 0 and not ragdollApplied then local alpha = 1 - math.exp(-12 * dt) if isHugging or isPunching then neck.Transform = neck.Transform:Lerp(CFrame.identity, alpha) elseif cam then local camLook = cam.CFrame.LookVector local rootLook = hrp.CFrame.LookVector local flatCam = Vector3.new(camLook.X, 0, camLook.Z) local flatRoot = Vector3.new(rootLook.X, 0, rootLook.Z) if flatCam.Magnitude > 0.01 and flatRoot.Magnitude > 0.01 then flatCam = flatCam.Unit flatRoot = flatRoot.Unit local crossY = flatRoot:Cross(flatCam).Y local dot = math.clamp(flatRoot:Dot(flatCam), -1, 1) local yaw = math.clamp(math.atan2(crossY, dot), -1.15, 1.15) local pitch = math.clamp(-math.asin(math.clamp(camLook.Y, -0.95, 0.95)), -0.65, 0.65) neck.Transform = neck.Transform:Lerp(CFrame.Angles(pitch, yaw, 0), alpha) end end end end) end end) local stepTimer = 0 local strideTime = 0 local wasInAir = false local fallStartY = nil RunService.Stepped:Connect(function(_, dt) pcall(function() local char = player.Character local hum = char and char:FindFirstChildOfClass("Humanoid") local hrp = char and char:FindFirstChild("HumanoidRootPart") if not char or not hum or not hrp then return end if punchCooldown > 0 then punchCooldown = math.max(0, punchCooldown - dt) end if hum.Health <= 0 and not ragdollApplied then applyCleanRagdoll(char, true) return end local inAir = hum:GetState() == Enum.HumanoidStateType.Freefall if inAir and fallStartY == nil then fallStartY = hrp.Position.Y elseif not inAir then if wasInAir and fallStartY ~= nil then local fallDistance = fallStartY - hrp.Position.Y if fallDistance >= HIGH_FALL_STUDS and not fallRagdollTriggered and not ragdollApplied then fallRagdollTriggered = true applyCleanRagdoll(char, false) fallStartY = nil wasInAir = false return end end fallStartY = nil end wasInAir = inAir nearestTargetRoot = findNearestPersonRoot(char, hrp) if not ragdollApplied and hum.Health > 0 then setActionBarVisible(nearestTargetRoot ~= nil) else setActionBarVisible(false) end local horizontalVel = Vector3.new(hrp.AssemblyLinearVelocity.X, 0, hrp.AssemblyLinearVelocity.Z) local speed = horizontalVel.Magnitude local smoothFactor = 1 - math.exp(-12 * dt) if dustEmitter then if not inAir and hum.Health > 0 and not ragdollApplied and speed > 1.5 then dustEmitter.Rate = (speed > 19) and 42 or 20 else dustEmitter.Rate = 0 end end if not ragdollApplied and not inAir and hum.Health > 0 and speed > 1.5 then local isRunning = speed > 19 local interval = isRunning and 0.25 or 0.39 stepTimer += dt if stepTimer >= interval then stepTimer = 0 playCleanStep(isRunning) end else stepTimer = 0 end if isHugging and not ragdollApplied and hum.Health > 0 then stopActiveTracks(char) setMovementLocked(char, true) hugTimer -= dt local squeeze = 0.5 - 0.5 * math.cos(math.clamp((1.35 - hugTimer) / 0.45, 0, 1) * math.pi) local isR6 = (currentRigType == Enum.HumanoidRigType.R6) if isR6 then setJointTarget("root", CFrame.new(0, 0, -0.08 * squeeze) * CFrame.Angles(0, 0, 0)) setJointTarget("lShoulder", CFrame.Angles(0, 0.35 * squeeze, -(math.pi * 0.5) + (0.35 * squeeze))) setJointTarget("rShoulder", CFrame.Angles(0, -0.35 * squeeze, (math.pi * 0.5) - (0.35 * squeeze))) setJointTarget("lHip", CFrame.identity) setJointTarget("rHip", CFrame.identity) else setJointTarget("root", CFrame.new(0, -0.04 * squeeze, -0.08 * squeeze) * CFrame.Angles(-0.06 * squeeze, 0, 0)) setJointTarget("waist", CFrame.Angles(-0.14 * squeeze, 0, 0)) setJointTarget("lShoulder", CFrame.Angles(-1.35 * squeeze, -0.45 * squeeze, -0.25 * squeeze)) setJointTarget("rShoulder", CFrame.Angles(-1.35 * squeeze, 0.45 * squeeze, 0.25 * squeeze)) setJointTarget("lHip", CFrame.identity) setJointTarget("rHip", CFrame.identity) end stepSmoothPose(dt, 18) if hugTimer <= 0 then isHugging = false setMovementLocked(char, false) restoreBaseTransforms() setAnimatePaused(false) end return end if isPunching and not ragdollApplied and hum.Health > 0 then stopActiveTracks(char) punchTimer -= dt local progress = math.clamp(1 - (punchTimer / 0.42), 0, 1) local strike = math.sin(progress * math.pi) local isR6 = (currentRigType == Enum.HumanoidRigType.R6) if not punchHitApplied and progress >= 0.38 then punchHitApplied = true applyRealDamageToNearby(char, hrp) end if isR6 then setJointTarget("root", CFrame.new(0, 0, -0.12 * strike) * CFrame.Angles(0, 0.18 * strike, 0)) setJointTarget("rShoulder", CFrame.Angles(0, -0.15 * strike, (math.pi * 0.5) + (0.15 * strike))) setJointTarget("lShoulder", CFrame.Angles(0, 0.2 * strike, -0.35 * strike)) setJointTarget("lHip", CFrame.Angles(0, 0, 0.14 * strike)) setJointTarget("rHip", CFrame.Angles(0, 0, -0.16 * strike)) else setJointTarget("root", CFrame.new(0, -0.02 * strike, -0.14 * strike) * CFrame.Angles(0, 0.22 * strike, 0)) setJointTarget("waist", CFrame.Angles(-0.12 * strike, 0.32 * strike, 0)) setJointTarget("rShoulder", CFrame.Angles(-1.55 * strike, 0.25 * strike, -0.12 * strike)) setJointTarget("lShoulder", CFrame.Angles(-0.55 * strike, -0.2 * strike, 0.25 * strike)) setJointTarget("lHip", CFrame.Angles(0.14 * strike, 0, 0)) setJointTarget("rHip", CFrame.Angles(-0.16 * strike, 0, 0)) end stepSmoothPose(dt, 22) if punchTimer <= 0 then isPunching = false restoreBaseTransforms() setAnimatePaused(false) end return end if not ragdollApplied and hum.Health > 0 then if not inAir and speed > 1.5 then local isRunning = speed > 19 strideTime += dt * (isRunning and 12 or 8) local swing = math.sin(strideTime) * (isRunning and 0.24 or 0.12) local armLag = math.sin(strideTime - 0.3) * (isRunning and 0.44 or 0.22) local counterSwing = math.sin(strideTime - 0.45) * (isRunning and 0.18 or 0.08) local bob = (0.5 - 0.5 * math.cos(strideTime * 2)) * (isRunning and 0.08 or 0.04) local lean = isRunning and 0.16 or 0.06 if currentRigType == Enum.HumanoidRigType.R6 then if joints.root then joints.root.Transform = joints.root.Transform:Lerp(CFrame.new(0, bob, 0) * CFrame.Angles(0, counterSwing * 0.25, 0), smoothFactor) end if joints.lShoulder then joints.lShoulder.Transform = joints.lShoulder.Transform:Lerp(CFrame.Angles(0, 0, armLag), smoothFactor) end if joints.rShoulder then joints.rShoulder.Transform = joints.rShoulder.Transform:Lerp(CFrame.Angles(0, 0, -armLag), smoothFactor) end if joints.lHip then joints.lHip.Transform = joints.lHip.Transform:Lerp(CFrame.Angles(0, 0, -swing), smoothFactor) end if joints.rHip then joints.rHip.Transform = joints.rHip.Transform:Lerp(CFrame.Angles(0, 0, swing), smoothFactor) end else local lx, ly, lz = armForward(currentRigType, armLag, -0.06) local rx, ry, rz = armForward(currentRigType, -armLag, 0.06) local lhx, lhy, lhz = legForward(currentRigType, -swing) local rhx, rhy, rhz = legForward(currentRigType, swing) if joints.root then joints.root.Transform = joints.root.Transform:Lerp(CFrame.new(0, bob, 0) * CFrame.Angles(0, counterSwing * 0.35, 0), smoothFactor) end if joints.waist then joints.waist.Transform = joints.waist.Transform:Lerp(CFrame.Angles(lean, -counterSwing, 0), smoothFactor) end if joints.lShoulder then joints.lShoulder.Transform = joints.lShoulder.Transform:Lerp(CFrame.Angles(lx, ly, lz), smoothFactor) end if joints.rShoulder then joints.rShoulder.Transform = joints.rShoulder.Transform:Lerp(CFrame.Angles(rx, ry, rz), smoothFactor) end if joints.lHip then joints.lHip.Transform = joints.lHip.Transform:Lerp(CFrame.Angles(lhx, lhy, lhz), smoothFactor) end if joints.rHip then joints.rHip.Transform = joints.rHip.Transform:Lerp(CFrame.Angles(rhx, rhy, rhz), smoothFactor) end end else strideTime = 0 end end end) end) local function bindCharacter(newChar) if not newChar then return end pcall(function() character = newChar currentRigType = detectRigType(character) joints = getJoints(character, currentRigType) ragdollApplied = false fallRagdollTriggered = false isHugging = false hugTimer = 0 isPunching = false punchTimer = 0 punchCooldown = 0 savedWalkSpeed = nil savedJumpPower = nil savedJumpHeight = nil savedUseJumpPower = nil fallStartY = nil wasInAir = false stepTimer = 0 strideTime = 0 setupDustParticleEffect(character) local hum = character:FindFirstChildOfClass("Humanoid") or character:WaitForChild("Humanoid", 3) if hum then currentRigType = hum.RigType joints = getJoints(character, currentRigType) hum.BreakJointsOnDeath = false hum.Died:Connect(function() applyCleanRagdoll(character, true) end) end pcall(createPunchButtonNextToJump) if punchButton then punchButton.MouseButton1Click:Connect(triggerPunch) end end) end pcall(function() setLoaderStatus("Cargando detector de rig y articulaciones...") setLoaderStatus("Descargando sonidos de pasos, caída, muerte y golpes...") setLoaderStatus("Descargando partículas de polvo al correr...") setLoaderStatus("Descargando abrazar, lanzar y golpear...") end) if character then bindCharacter(character) end player.CharacterAdded:Connect(bindCharacter) pcall(function() setLoaderStatus(HUB_NAME .. " listo.") dismissLoader() end)