Mr_3242

R15 to R6 fe

Jun 3rd, 2026
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.49 KB | None | 0 0
  1. ------------------------------------------------------------
  2. ---- R6 Character ----
  3. ------------------------------------------------------------
  4.  
  5. local plr = game.Players.LocalPlayer
  6.  
  7. local Main = game.Players:GetHumanoidDescriptionFromUserId(plr.CharacterAppearanceId)
  8. local morph = game.Players:CreateHumanoidModelFromDescription(Main, Enum.HumanoidRigType.R6)
  9. local oldchar = plr.Character
  10.  
  11. morph:SetPrimaryPartCFrame(plr.Character.PrimaryPart.CFrame)
  12. morph.Name = plr.Name
  13. plr.Character = morph
  14. morph.Parent = workspace
  15.  
  16. oldchar:Destroy()
  17.  
  18. ------------------------------------------------------------
  19. ---- R6 Animation ----
  20. ------------------------------------------------------------
  21.  
  22. wait(.1)
  23.  
  24. local Figure = morph
  25. local Torso = Figure:WaitForChild("Torso")
  26. local RightShoulder = Torso:WaitForChild("Right Shoulder")
  27. local LeftShoulder = Torso:WaitForChild("Left Shoulder")
  28. local RightHip = Torso:WaitForChild("Right Hip")
  29. local LeftHip = Torso:WaitForChild("Left Hip")
  30. local Neck = Torso:WaitForChild("Neck")
  31. local Humanoid = Figure:WaitForChild("Humanoid")
  32. local pose = "Standing"
  33.  
  34. local currentAnim = ""
  35. local currentAnimInstance = nil
  36. local currentAnimTrack = nil
  37. local currentAnimKeyframeHandler = nil
  38. local currentAnimSpeed = 1.0
  39. local animTable = {}
  40. local animNames = {
  41. idle = {
  42. { id = "http://www.roblox.com/asset/?id=180435571", weight = 9 },
  43. { id = "http://www.roblox.com/asset/?id=180435792", weight = 1 }
  44. },
  45. walk = {
  46. { id = "http://www.roblox.com/asset/?id=180426354", weight = 10 }
  47. },
  48. run = {
  49. { id = "run.xml", weight = 10 }
  50. },
  51. jump = {
  52. { id = "http://www.roblox.com/asset/?id=125750702", weight = 10 }
  53. },
  54. fall = {
  55. { id = "http://www.roblox.com/asset/?id=180436148", weight = 10 }
  56. },
  57. climb = {
  58. { id = "http://www.roblox.com/asset/?id=180436334", weight = 10 }
  59. },
  60. sit = {
  61. { id = "http://www.roblox.com/asset/?id=178130996", weight = 10 }
  62. },
  63. toolnone = {
  64. { id = "http://www.roblox.com/asset/?id=182393478", weight = 10 }
  65. },
  66. toolslash = {
  67. { id = "http://www.roblox.com/asset/?id=129967390", weight = 10 }
  68. -- { id = "slash.xml", weight = 10 }
  69.  
  70. },
  71. toollunge = {
  72. { id = "http://www.roblox.com/asset/?id=129967478", weight = 10 }
  73. },
  74. wave = {
  75. { id = "http://www.roblox.com/asset/?id=128777973", weight = 10 }
  76. },
  77. point = {
  78. { id = "http://www.roblox.com/asset/?id=128853357", weight = 10 }
  79. },
  80. dance1 = {
  81. { id = "http://www.roblox.com/asset/?id=182435998", weight = 10 },
  82. { id = "http://www.roblox.com/asset/?id=182491037", weight = 10 },
  83. { id = "http://www.roblox.com/asset/?id=182491065", weight = 10 }
  84. },
  85. dance2 = {
  86. { id = "http://www.roblox.com/asset/?id=182436842", weight = 10 },
  87. { id = "http://www.roblox.com/asset/?id=182491248", weight = 10 },
  88. { id = "http://www.roblox.com/asset/?id=182491277", weight = 10 }
  89. },
  90. dance3 = {
  91. { id = "http://www.roblox.com/asset/?id=182436935", weight = 10 },
  92. { id = "http://www.roblox.com/asset/?id=182491368", weight = 10 },
  93. { id = "http://www.roblox.com/asset/?id=182491423", weight = 10 }
  94. },
  95. laugh = {
  96. { id = "http://www.roblox.com/asset/?id=129423131", weight = 10 }
  97. },
  98. cheer = {
  99. { id = "http://www.roblox.com/asset/?id=129423030", weight = 10 }
  100. },
  101. }
  102. local dances = {"dance1", "dance2", "dance3"}
  103.  
  104. -- Existance in this list signifies that it is an emote, the value indicates if it is a looping emote
  105.  
  106. local emoteNames = { wave = false, point = false, dance1 = true, dance2 = true, dance3 = true, laugh = false, cheer = false}
  107.  
  108. function configureAnimationSet(name, fileList)
  109. if (animTable[name] ~= nil) then
  110. for _, connection in pairs(animTable[name].connections) do
  111. connection:disconnect()
  112. end
  113. end
  114. animTable[name] = {}
  115. animTable[name].count = 0
  116. animTable[name].totalWeight = 0
  117. animTable[name].connections = {}
  118.  
  119. -- check for config values
  120.  
  121. local config = morph:FindFirstChild(name)
  122. if (config ~= nil) then
  123. -- print("Loading anims " .. name)
  124.  
  125. table.insert(animTable[name].connections, config.ChildAdded:connect(function(child) configureAnimationSet(name, fileList) end))
  126. table.insert(animTable[name].connections, config.ChildRemoved:connect(function(child) configureAnimationSet(name, fileList) end))
  127. local idx = 1
  128. for _, childPart in pairs(config:GetChildren()) do
  129. if (childPart:IsA("Animation")) then
  130. table.insert(animTable[name].connections, childPart.Changed:connect(function(property) configureAnimationSet(name, fileList) end))
  131. animTable[name][idx] = {}
  132. animTable[name][idx].anim = childPart
  133. local weightObject = childPart:FindFirstChild("Weight")
  134. if (weightObject == nil) then
  135. animTable[name][idx].weight = 1
  136. else
  137. animTable[name][idx].weight = weightObject.Value
  138. end
  139. animTable[name].count = animTable[name].count + 1
  140. animTable[name].totalWeight = animTable[name].totalWeight + animTable[name][idx].weight
  141. -- print(name .. " [" .. idx .. "] " .. animTable[name][idx].anim.AnimationId .. " (" .. animTable[name][idx].weight .. ")")
  142.  
  143. idx = idx + 1
  144. end
  145. end
  146. end
  147.  
  148. -- fallback to defaults
  149.  
  150. if (animTable[name].count <= 0) then
  151. for idx, anim in pairs(fileList) do
  152. animTable[name][idx] = {}
  153. animTable[name][idx].anim = Instance.new("Animation")
  154. animTable[name][idx].anim.Name = name
  155. animTable[name][idx].anim.AnimationId = anim.id
  156. animTable[name][idx].weight = anim.weight
  157. animTable[name].count = animTable[name].count + 1
  158. animTable[name].totalWeight = animTable[name].totalWeight + anim.weight
  159. -- print(name .. " [" .. idx .. "] " .. anim.id .. " (" .. anim.weight .. ")")
  160.  
  161. end
  162. end
  163. end
  164.  
  165. -- Setup animation objects
  166.  
  167. function scriptChildModified(child)
  168. local fileList = animNames[child.Name]
  169. if (fileList ~= nil) then
  170. configureAnimationSet(child.Name, fileList)
  171. end
  172. end
  173.  
  174. morph.ChildAdded:connect(scriptChildModified)
  175. morph.ChildRemoved:connect(scriptChildModified)
  176.  
  177.  
  178. for name, fileList in pairs(animNames) do
  179. configureAnimationSet(name, fileList)
  180. end
  181.  
  182. -- ANIMATION
  183.  
  184.  
  185. -- declarations
  186.  
  187. local toolAnim = "None"
  188. local toolAnimTime = 0
  189.  
  190. local jumpAnimTime = 0
  191. local jumpAnimDuration = 0.3
  192.  
  193. local toolTransitionTime = 0.1
  194. local fallTransitionTime = 0.3
  195. local jumpMaxLimbVelocity = 0.75
  196.  
  197. -- functions
  198.  
  199.  
  200. function stopAllAnimations()
  201. local oldAnim = currentAnim
  202.  
  203. -- return to idle if finishing an emote
  204.  
  205. if (emoteNames[oldAnim] ~= nil and emoteNames[oldAnim] == false) then
  206. oldAnim = "idle"
  207. end
  208.  
  209. currentAnim = ""
  210. currentAnimInstance = nil
  211. if (currentAnimKeyframeHandler ~= nil) then
  212. currentAnimKeyframeHandler:disconnect()
  213. end
  214.  
  215. if (currentAnimTrack ~= nil) then
  216. currentAnimTrack:Stop()
  217. currentAnimTrack:Destroy()
  218. currentAnimTrack = nil
  219. end
  220. return oldAnim
  221. end
  222.  
  223. function setAnimationSpeed(speed)
  224. if speed ~= currentAnimSpeed then
  225. currentAnimSpeed = speed
  226. currentAnimTrack:AdjustSpeed(currentAnimSpeed)
  227. end
  228. end
  229.  
  230. function keyFrameReachedFunc(frameName)
  231. if (frameName == "End") then
  232.  
  233. local repeatAnim = currentAnim
  234. -- return to idle if finishing an emote
  235.  
  236. if (emoteNames[repeatAnim] ~= nil and emoteNames[repeatAnim] == false) then
  237. repeatAnim = "idle"
  238. end
  239.  
  240. local animSpeed = currentAnimSpeed
  241. playAnimation(repeatAnim, 0.0, Humanoid)
  242. setAnimationSpeed(animSpeed)
  243. end
  244. end
  245.  
  246. -- Preload animations
  247.  
  248. function playAnimation(animName, transitionTime, humanoid)
  249.  
  250. local roll = math.random(1, animTable[animName].totalWeight)
  251. local origRoll = roll
  252. local idx = 1
  253. while (roll > animTable[animName][idx].weight) do
  254. roll = roll - animTable[animName][idx].weight
  255. idx = idx + 1
  256. end
  257. -- print(animName .. " " .. idx .. " [" .. origRoll .. "]")
  258.  
  259. local anim = animTable[animName][idx].anim
  260.  
  261. -- switch animation
  262.  
  263. if (anim ~= currentAnimInstance) then
  264.  
  265. if (currentAnimTrack ~= nil) then
  266. currentAnimTrack:Stop(transitionTime)
  267. currentAnimTrack:Destroy()
  268. end
  269.  
  270. currentAnimSpeed = 1.0
  271.  
  272. -- load it to the humanoid; get AnimationTrack
  273.  
  274. currentAnimTrack = humanoid:LoadAnimation(anim)
  275. currentAnimTrack.Priority = Enum.AnimationPriority.Core
  276.  
  277. -- play the animation
  278.  
  279. currentAnimTrack:Play(transitionTime)
  280. currentAnim = animName
  281. currentAnimInstance = anim
  282.  
  283. -- set up keyframe name triggers
  284.  
  285. if (currentAnimKeyframeHandler ~= nil) then
  286. currentAnimKeyframeHandler:disconnect()
  287. end
  288. currentAnimKeyframeHandler = currentAnimTrack.KeyframeReached:connect(keyFrameReachedFunc)
  289.  
  290. end
  291.  
  292. end
  293.  
  294. -------------------------------------------------------------------------------------------
  295.  
  296. -------------------------------------------------------------------------------------------
  297.  
  298.  
  299. local toolAnimName = ""
  300. local toolAnimTrack = nil
  301. local toolAnimInstance = nil
  302. local currentToolAnimKeyframeHandler = nil
  303.  
  304. function toolKeyFrameReachedFunc(frameName)
  305. if (frameName == "End") then
  306. -- print("Keyframe : ".. frameName)
  307.  
  308. playToolAnimation(toolAnimName, 0.0, Humanoid)
  309. end
  310. end
  311.  
  312.  
  313. function playToolAnimation(animName, transitionTime, humanoid, priority)
  314.  
  315. local roll = math.random(1, animTable[animName].totalWeight)
  316. local origRoll = roll
  317. local idx = 1
  318. while (roll > animTable[animName][idx].weight) do
  319. roll = roll - animTable[animName][idx].weight
  320. idx = idx + 1
  321. end
  322. -- print(animName .. " * " .. idx .. " [" .. origRoll .. "]")
  323.  
  324. local anim = animTable[animName][idx].anim
  325.  
  326. if (toolAnimInstance ~= anim) then
  327.  
  328. if (toolAnimTrack ~= nil) then
  329. toolAnimTrack:Stop()
  330. toolAnimTrack:Destroy()
  331. transitionTime = 0
  332. end
  333.  
  334. -- load it to the humanoid; get AnimationTrack
  335.  
  336. toolAnimTrack = humanoid:LoadAnimation(anim)
  337. if priority then
  338. toolAnimTrack.Priority = priority
  339. end
  340.  
  341. -- play the animation
  342.  
  343. toolAnimTrack:Play(transitionTime)
  344. toolAnimName = animName
  345. toolAnimInstance = anim
  346.  
  347. currentToolAnimKeyframeHandler = toolAnimTrack.KeyframeReached:connect(toolKeyFrameReachedFunc)
  348. end
  349. end
  350.  
  351. function stopToolAnimations()
  352. local oldAnim = toolAnimName
  353.  
  354. if (currentToolAnimKeyframeHandler ~= nil) then
  355. currentToolAnimKeyframeHandler:disconnect()
  356. end
  357.  
  358. toolAnimName = ""
  359. toolAnimInstance = nil
  360. if (toolAnimTrack ~= nil) then
  361. toolAnimTrack:Stop()
  362. toolAnimTrack:Destroy()
  363. toolAnimTrack = nil
  364. end
  365.  
  366.  
  367. return oldAnim
  368. end
  369.  
  370. -------------------------------------------------------------------------------------------
  371.  
  372. -------------------------------------------------------------------------------------------
  373.  
  374.  
  375.  
  376. function onRunning(speed)
  377. if speed > 0.01 then
  378. playAnimation("walk", 0.1, Humanoid)
  379. if currentAnimInstance and currentAnimInstance.AnimationId == "http://www.roblox.com/asset/?id=180426354" then
  380. setAnimationSpeed(speed / 14.5)
  381. end
  382. pose = "Running"
  383. else
  384. if emoteNames[currentAnim] == nil then
  385. playAnimation("idle", 0.1, Humanoid)
  386. pose = "Standing"
  387. end
  388. end
  389. end
  390.  
  391. function onDied()
  392. pose = "Dead"
  393. end
  394.  
  395. function onJumping()
  396. playAnimation("jump", 0.1, Humanoid)
  397. jumpAnimTime = jumpAnimDuration
  398. pose = "Jumping"
  399. end
  400.  
  401. function onClimbing(speed)
  402. playAnimation("climb", 0.1, Humanoid)
  403. setAnimationSpeed(speed / 12.0)
  404. pose = "Climbing"
  405. end
  406.  
  407. function onGettingUp()
  408. pose = "GettingUp"
  409. end
  410.  
  411. function onFreeFall()
  412. if (jumpAnimTime <= 0) then
  413. playAnimation("fall", fallTransitionTime, Humanoid)
  414. end
  415. pose = "FreeFall"
  416. end
  417.  
  418. function onFallingDown()
  419. pose = "FallingDown"
  420. end
  421.  
  422. function onSeated()
  423. pose = "Seated"
  424. end
  425.  
  426. function onPlatformStanding()
  427. pose = "PlatformStanding"
  428. end
  429.  
  430. function onSwimming(speed)
  431. if speed > 0 then
  432. pose = "Running"
  433. else
  434. pose = "Standing"
  435. end
  436. end
  437.  
  438. function getTool()
  439. for _, kid in ipairs(Figure:GetChildren()) do
  440. if kid.className == "Tool" then return kid end
  441. end
  442. return nil
  443. end
  444.  
  445. function getToolAnim(tool)
  446. for _, c in ipairs(tool:GetChildren()) do
  447. if c.Name == "toolanim" and c.className == "StringValue" then
  448. return c
  449. end
  450. end
  451. return nil
  452. end
  453.  
  454. function animateTool()
  455.  
  456. if (toolAnim == "None") then
  457. playToolAnimation("toolnone", toolTransitionTime, Humanoid, Enum.AnimationPriority.Idle)
  458. return
  459. end
  460.  
  461. if (toolAnim == "Slash") then
  462. playToolAnimation("toolslash", 0, Humanoid, Enum.AnimationPriority.Action)
  463. return
  464. end
  465.  
  466. if (toolAnim == "Lunge") then
  467. playToolAnimation("toollunge", 0, Humanoid, Enum.AnimationPriority.Action)
  468. return
  469. end
  470. end
  471.  
  472. function moveSit()
  473. RightShoulder.MaxVelocity = 0.15
  474. LeftShoulder.MaxVelocity = 0.15
  475. RightShoulder:SetDesiredAngle(3.14 /2)
  476. LeftShoulder:SetDesiredAngle(-3.14 /2)
  477. RightHip:SetDesiredAngle(3.14 /2)
  478. LeftHip:SetDesiredAngle(-3.14 /2)
  479. end
  480.  
  481. local lastTick = 0
  482.  
  483. function move(time)
  484. local amplitude = 1
  485. local frequency = 1
  486. local deltaTime = time - lastTick
  487. lastTick = time
  488.  
  489. local climbFudge = 0
  490. local setAngles = false
  491.  
  492. if (jumpAnimTime > 0) then
  493. jumpAnimTime = jumpAnimTime - deltaTime
  494. end
  495.  
  496. if (pose == "FreeFall" and jumpAnimTime <= 0) then
  497. playAnimation("fall", fallTransitionTime, Humanoid)
  498. elseif (pose == "Seated") then
  499. playAnimation("sit", 0.5, Humanoid)
  500. return
  501. elseif (pose == "Running") then
  502. playAnimation("walk", 0.1, Humanoid)
  503. elseif (pose == "Dead" or pose == "GettingUp" or pose == "FallingDown" or pose == "Seated" or pose == "PlatformStanding") then
  504. -- print("Wha " .. pose)
  505.  
  506. stopAllAnimations()
  507. amplitude = 0.1
  508. frequency = 1
  509. setAngles = true
  510. end
  511.  
  512. if (setAngles) then
  513. local desiredAngle = amplitude * math.sin(time * frequency)
  514.  
  515. RightShoulder:SetDesiredAngle(desiredAngle + climbFudge)
  516. LeftShoulder:SetDesiredAngle(desiredAngle - climbFudge)
  517. RightHip:SetDesiredAngle(-desiredAngle)
  518. LeftHip:SetDesiredAngle(-desiredAngle)
  519. end
  520.  
  521. -- Tool Animation handling
  522.  
  523. local tool = getTool()
  524. if tool and tool:FindFirstChild("Handle") then
  525.  
  526. local animStringValueObject = getToolAnim(tool)
  527.  
  528. if animStringValueObject then
  529. toolAnim = animStringValueObject.Value
  530. -- message recieved, delete StringValue
  531.  
  532. animStringValueObject.Parent = nil
  533. toolAnimTime = time + .3
  534. end
  535.  
  536. if time > toolAnimTime then
  537. toolAnimTime = 0
  538. toolAnim = "None"
  539. end
  540.  
  541. animateTool()
  542. else
  543. stopToolAnimations()
  544. toolAnim = "None"
  545. toolAnimInstance = nil
  546. toolAnimTime = 0
  547. end
  548. end
  549.  
  550. -- connect events
  551.  
  552. Humanoid.Died:connect(onDied)
  553. Humanoid.Running:connect(onRunning)
  554. Humanoid.Jumping:connect(onJumping)
  555. Humanoid.Climbing:connect(onClimbing)
  556. Humanoid.GettingUp:connect(onGettingUp)
  557. Humanoid.FreeFalling:connect(onFreeFall)
  558. Humanoid.FallingDown:connect(onFallingDown)
  559. Humanoid.Seated:connect(onSeated)
  560. Humanoid.PlatformStanding:connect(onPlatformStanding)
  561. Humanoid.Swimming:connect(onSwimming)
  562.  
  563. -- setup emote chat hook
  564.  
  565. game:GetService("Players").LocalPlayer.Chatted:connect(function(msg)
  566. local emote = ""
  567. if msg == "/e dance" then
  568. emote = dances[math.random(1, #dances)]
  569. elseif (string.sub(msg, 1, 3) == "/e ") then
  570. emote = string.sub(msg, 4)
  571. elseif (string.sub(msg, 1, 7) == "/emote ") then
  572. emote = string.sub(msg, 8)
  573. end
  574.  
  575. if (pose == "Standing" and emoteNames[emote] ~= nil) then
  576. playAnimation(emote, 0.1, Humanoid)
  577. end
  578.  
  579. end)
  580.  
  581.  
  582. -- main program
  583.  
  584.  
  585. -- initialize to idle
  586.  
  587. playAnimation("idle", 0.1, Humanoid)
  588. pose = "Standing"
  589.  
  590. while Figure.Parent ~= nil do
  591. local _, time = wait(0.1)
  592. move(time)
  593. end
  594.  
  595. ------------------------------------------------------------
  596. ---- Humanoid Health ----
  597. ------------------------------------------------------------
  598.  
  599.  
  600. -- Gradually regenerates the Humanoid's Health over time.
  601.  
  602.  
  603. local REGEN_RATE = 1/100 -- Regenerate this fraction of MaxHealth per second.
  604.  
  605. local REGEN_STEP = 1 -- Wait this long between each regeneration step.
  606.  
  607.  
  608. --------------------------------------------------------------------------------
  609.  
  610.  
  611. local Character = morph
  612. local Humanoid = Character:WaitForChild'Humanoid'
  613.  
  614. --------------------------------------------------------------------------------
  615.  
  616.  
  617. while true do
  618. while Humanoid.Health < Humanoid.MaxHealth do
  619. local dt = wait(REGEN_STEP)
  620. local dh = dt*REGEN_RATE*Humanoid.MaxHealth
  621. Humanoid.Health = math.min(Humanoid.Health + dh, Humanoid.MaxHealth)
  622. end
  623. Humanoid.HealthChanged:Wait()
  624. end
  625.  
  626. -- This Is All R6 Function Made By 00de0l end end
Add Comment
Please, Sign In to add comment