Advertisement
1x1x1x1IAMbck

Old Hollow Knight Logic Handler Lua

Jul 8th, 2025
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 42.20 KB | None | 0 0
  1. --[[
  2.     Creator: YeahLamma
  3.     Description: Hollow Knight game handler on client side.
  4.     Creator notes: This is an year old code, did not used to comment stuff,
  5.         since I remember most stuff where everything is and how is used.
  6.         Nowdays I only use commenting only in group projects or when its
  7.         example of data transfer between client and server and vise versa.
  8. ]]
  9.  
  10. local char = script.Parent
  11. local plr = game.Players:GetPlayerFromCharacter(char)
  12. local data = char.Data
  13. local UIS = game:GetService("UserInputService")
  14. local ZPModule = require(game.ReplicatedStorage.ModuleScripts.Zone)
  15. local remots = game.ReplicatedStorage.Remotes
  16. local showbox = require(game.ReplicatedStorage.ModuleScripts.HitboxVisible)
  17. local effects = require(game.ReplicatedStorage.ModuleScripts.Effects)
  18. local AIModule = require(game.ReplicatedStorage.ModuleScripts.AIs)
  19.  
  20. repeat task.wait() until plr:FindFirstChild("loadedData") and plr.PlayerGui:FindFirstChild("Interface")
  21.  
  22. local function waitForInputType(inputType)
  23.     while true do
  24.         local input, processed = UIS.InputBegan:Wait()
  25.         if processed then continue end
  26.         if input.KeyCode == inputType then break end
  27.     end
  28. end
  29.  
  30. local function roomLoad(roomName, SavePoint)
  31.     plr.PlayerGui.Interface.Fade.BackgroundTransparency = 0
  32.     char.HumanoidRootPart.Anchored = true
  33.     local splitRoomName = string.split(roomName, ":")
  34.     char.Data.Room.Value = splitRoomName[1] or roomName
  35.     local room = game.ReplicatedStorage.Rooms:FindFirstChild(char.Data.Room.Value):Clone()
  36.  
  37.     if workspace:FindFirstChild("Render") then
  38.         for i, v in pairs(workspace.Render.Background:GetChildren()) do
  39.             for _, v2 in pairs(room.Background:GetChildren()) do
  40.                 if v2.SoundId == v.SoundId then
  41.                     v2.TimePosition = v.TimePosition
  42.                 end
  43.             end
  44.         end
  45.        
  46.         workspace.Render:Destroy()
  47.     end
  48.     room.Name = "Render"
  49.     room.Parent = workspace
  50.     if not SavePoint then
  51.         if not splitRoomName[2] then
  52.             if char.Data.LastRoom.Value == "" or not room.TeleportPoints:FindFirstChild(char.Data.LastRoom.Value) then
  53.                 char:MoveTo(room.TeleportPoints.Default.Position)
  54.             else
  55.                 char:MoveTo(room.TeleportPoints:FindFirstChild(char.Data.LastRoom.Value).Position)
  56.             end
  57.         else
  58.             char.Data.Checkpoint.Value = room.TeleportPoints:FindFirstChild(splitRoomName[2])
  59.             char:MoveTo(room.TeleportPoints:FindFirstChild(splitRoomName[2]).Position)
  60.         end
  61.     else
  62.         if not room:FindFirstChild("SavePoint") then
  63.             char:MoveTo(room.TeleportPoints.Default.Position)
  64.             char.Data.Checkpoint.Value = room.TeleportPoints.Default
  65.         else
  66.             char:MoveTo(room.SavePoint.Position)
  67.             char.Data.Checkpoint.Value = room.SavePoint
  68.  
  69.         end
  70.         for i, v in pairs(plr.Data:GetChildren()) do
  71.             if char.Data:FindFirstChild(v.Name) and not v:IsA("Folder") then
  72.                 char.Data:FindFirstChild(v.Name).Value = v.Value
  73.             end
  74.         end
  75.         char.Data.Lives.Value = char.Data.MaxLives.Value
  76.         char.Data.Mana.Value = 100
  77.         char.Data.RoomData:ClearAllChildren()
  78.         for i, v in pairs(plr.Data.RoomData:GetChildren()) do
  79.             v:Clone().Parent = char.Data.RoomData
  80.         end
  81.     end
  82.  
  83.     for i, v in pairs(room:GetDescendants()) do
  84.         if v.Name == "Save" then
  85.             if char.Data.RoomData:FindFirstChild(v.Value) then
  86.                 v.Parent.Parent:Destroy()
  87.             end
  88.         elseif v.Name == "PlayLoopSound" then
  89.             local loopSound = game.ReplicatedStorage.Sounds:FindFirstChild(v.Value):Clone()
  90.             loopSound.Parent = v.Parent.Parent.Hitbox
  91.             loopSound:Play()
  92.         end
  93.     end
  94.     if room:FindFirstChild("SceneJumps") then
  95.         for i, v in pairs(room.SceneJumps:GetChildren()) do
  96.             if not v:FindFirstChild("Input") then
  97.                 v.Touched:Connect(function(hit)
  98.                     if hit:IsDescendantOf(char) then
  99.                         char.Data.LastRoom.Value = char.Data.Room.Value
  100.                         roomLoad(v.Name)
  101.                     end
  102.                 end)
  103.             else
  104.                 local SP = ZPModule.new(v)
  105.                 local inside = false
  106.                 local TEXTO = nil
  107.                 SP.playerEntered:Connect(function(plyr: Player)
  108.                     if plyr == plr then
  109.                         inside = true
  110.  
  111.                         if TEXTO == nil then
  112.                             TEXTO = script.RandomText:Clone()
  113.                             TEXTO.Text = "Press W to enter"
  114.                             TEXTO.Parent = plr.PlayerGui.Interface
  115.                         end
  116.  
  117.                         while true do
  118.                             if inside == false then break end
  119.                             local input, processed = UIS.InputBegan:Wait()
  120.                             if processed then continue end
  121.                             if input.KeyCode == Enum.KeyCode.W then break end
  122.                         end                    
  123.                         if inside == true then
  124.                             if game.ReplicatedStorage.Rooms:FindFirstChild(string.split(v.Name, ":")[1]) then
  125.                                 char.Data.LastRoom.Value = char.Data.Room.Value
  126.                                 roomLoad(v.Name)
  127.                             end
  128.                             if TEXTO ~= nil then
  129.                                 TEXTO:Destroy()
  130.                                 TEXTO = nil
  131.                             end
  132.                         end
  133.                     end
  134.                 end)
  135.  
  136.                 SP.playerExited:Connect(function(plyr: Player)
  137.                     if plyr == plr then
  138.                         inside = false
  139.                         if TEXTO then
  140.                             TEXTO:Destroy()
  141.                             TEXTO = nil
  142.                         end
  143.                     end
  144.                 end)
  145.             end
  146.         end
  147.     end
  148.  
  149.     if room:FindFirstChild("Spikes") then
  150.         for i, v in pairs(room.Spikes:GetChildren()) do
  151.             if v.Data:FindFirstChild("Moving") then
  152.                 local destinations = {}
  153.                 for _, val in pairs(string.split(v.Data.Moving.Value, ":")) do
  154.                     if v:FindFirstChild(val) then
  155.                         table.insert(destinations, v:FindFirstChild(val))
  156.                     end
  157.                 end
  158.                 spawn(function()
  159.                     local dest = false
  160.                     while v and v:FindFirstChild("Hitbox") do
  161.                         if dest == false then
  162.                             game.TweenService:Create(v.Hitbox, TweenInfo.new(v.Data:FindFirstChild("Timer") and v.Data:FindFirstChild("Timer").Value  or 1.7, Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut), {Position = destinations[2].Position}):Play()
  163.                             task.wait(2.3)
  164.                             dest = true
  165.                         else
  166.                             game.TweenService:Create(v.Hitbox, TweenInfo.new(v.Data:FindFirstChild("Timer") and v.Data:FindFirstChild("Timer").Value or 1.7, Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut), {Position = destinations[1].Position}):Play()
  167.                             task.wait(2.3)
  168.                             dest = false
  169.                         end
  170.                     end
  171.                 end)
  172.             end
  173.  
  174.             v.Hitbox.Touched:Connect(function(hit)
  175.                 if hit.Name == "Hitbox"and hit:IsDescendantOf(char) and not char.Data:FindFirstChild("IFRAME") then
  176.                     if char.Data.Lives.Value > 1 then
  177.  
  178.                         local iframespike = Instance.new("StringValue")
  179.                         iframespike.Name = "IFRAME"
  180.                         iframespike.Parent = char.Data
  181.                         game.Debris:AddItem(iframespike, 1.3)
  182.  
  183.                         char.Data.Lives.Value -= 1
  184.                         char.HumanoidRootPart.Anchored = true
  185.                         task.wait(0.3)
  186.                         game.TweenService:Create(plr.PlayerGui.Interface.Fade, TweenInfo.new(.15), {BackgroundTransparency = 0}):Play()
  187.                         char:MoveTo(char.Data.Checkpoint.Value.Position or room.TeleportPoints.Default.Position)
  188.                         task.wait(1)
  189.                         char.HumanoidRootPart.Anchored = false
  190.                         game.TweenService:Create(plr.PlayerGui.Interface.Fade, TweenInfo.new(.15), {BackgroundTransparency = 1}):Play()
  191.                     else
  192.                         char.Data.Lives.Value = 0
  193.                     end
  194.                 end
  195.             end)
  196.         end
  197.     end
  198.  
  199.     if room:FindFirstChild("Zones") then
  200.         for i, v in pairs(room.Zones:GetChildren()) do
  201.             local zoneZP = ZPModule.new(v)
  202.             local conn = nil
  203.             local TEXTO = nil
  204.  
  205.             zoneZP.playerEntered:Connect(function(plyr: Player)
  206.                 if plyr == plr then
  207.                     local inside = true
  208.  
  209.                     conn = zoneZP.playerExited:Connect(function(plyr: Player)
  210.                         if plyr == plr then
  211.                             inside = false
  212.                             if TEXTO then
  213.                                 TEXTO:Destroy()
  214.                                 TEXTO = nil
  215.                             end
  216.                             conn:Disconnect()
  217.                         end
  218.                     end)
  219.                     if v.Data.TypeZone.Value == "RemovePart" then
  220.                         if v.Data:FindFirstChild("Save") then
  221.                             local change = Instance.new("StringValue")
  222.                             change.Name = v.Data.Save.Value
  223.                             change.Parent = char.Data.RoomData
  224.                         end
  225.                         v.Data.Remover.Value:Destroy()
  226.                         v:Destroy()
  227.                     elseif v.Data.TypeZone.Value == "SetSpawnpoint" then
  228.                         if char.Data.Checkpoint.Value ~= v.Data.Checkpoint.Value then
  229.                             char.Data.Checkpoint.Value = v.Data.Checkpoint.Value
  230.  
  231.                         end
  232.  
  233.                     elseif v.Data.TypeZone.Value == "UpgradeAbility" then
  234.                         if TEXTO == nil then
  235.                             TEXTO = script.RandomText:Clone()
  236.                             TEXTO.Text = "Press W to Pick Up"
  237.                             TEXTO.Parent = plr.PlayerGui.Interface
  238.                         end
  239.                         waitForInputType(Enum.KeyCode.W)
  240.                         if inside then
  241.                             local skillUp = string.split(v.Data.Skill.Value, ":")
  242.                             char.Data:FindFirstChild(skillUp[1]).Value = skillUp[2]
  243.                             if v.Data:FindFirstChild("Save") then
  244.                                 local change = Instance.new("StringValue")
  245.                                 change.Name = v.Data.Save.Value
  246.                                 change.Parent = char.Data.RoomData
  247.                                 v:Destroy()
  248.                             end
  249.                             if TEXTO ~= nil then
  250.                                 TEXTO:Destroy()
  251.                                 TEXTO = nil
  252.                             end
  253.                         end
  254.                     elseif v.Data.TypeZone.Value == "TextAppear" then                      
  255.                         waitForInputType(Enum.KeyCode.W)
  256.                         if inside then
  257.                             local TEXTO = script.RandomText:Clone()
  258.                             TEXTO.Text = v.Data.Title.Value
  259.                             TEXTO.Parent = plr.PlayerGui.Interface
  260.                             game.Debris:AddItem(TEXTO, 2)
  261.                             if v.Data:FindFirstChild("Save") then
  262.                                 local change = Instance.new("StringValue")
  263.                                 change.Name = v.Data.Save.Value
  264.                                 change.Parent = char.Data.RoomData
  265.                                 v:Destroy()
  266.                             end
  267.                         end
  268.                     elseif v.Data.TypeZone.Value == "PlaySound" then
  269.                         local soundo = v.Data.Object.Value:Clone()
  270.                         v:Destroy()
  271.                         soundo.Parent = workspace
  272.                         soundo:Play()
  273.                         game.Debris:AddItem(soundo, soundo.TimeLength +1)
  274.                     elseif v.Data.TypeZone.Value == "ChangeBackground" then
  275.                         local savedTime = room.Background:FindFirstChildOfClass("Sound").TimePosition
  276.                         for i, v in pairs(room.Background:GetChildren()) do
  277.                             if v:IsA("Sound") then
  278.                                 v:Stop()
  279.                             end
  280.                         end
  281.                        
  282.                         local soundo = v.Data.Object.Value:Clone()
  283.                         soundo.Parent = room.Background
  284.                         soundo.TimePosition = savedTime
  285.                         local fade = false
  286.                         if v.Data:FindFirstChild("Fade") then
  287.                             fade = true
  288.                             local savedVolume = soundo.Volume
  289.                             soundo.Volume = 0
  290.                             game.TweenService:Create(soundo, TweenInfo.new(0.75), {Volume = savedVolume}):Play()
  291.                         end
  292.                         soundo:Play()
  293.                        
  294.                     elseif v.Data.TypeZone.Value == "PlaySoundUntilLeave" then
  295.                         local soundo = v.Data.Object.Value:Clone()
  296.                         soundo.Parent = workspace
  297.                         local fade = false
  298.                         if v.Data:FindFirstChild("Fade") then
  299.                             fade = true
  300.                             local savedVolume = soundo.Volume
  301.                             soundo.Volume = 0
  302.                             game.TweenService:Create(soundo, TweenInfo.new(0.75), {Volume = savedVolume}):Play()
  303.                         end
  304.                         soundo:Play()
  305.                         --game.Debris:AddItem(soundo, soundo.TimeLength +1)
  306.                         spawn(function()
  307.                             repeat task.wait() until inside == false
  308.                             if fade then
  309.                                 game.TweenService:Create(soundo, TweenInfo.new(0.75), {Volume = 0}):Play()
  310.                                 task.wait(0.8)
  311.                                 soundo:Destroy()
  312.                             else
  313.                                 soundo:Destroy()
  314.                             end
  315.                         end)
  316.                     end
  317.                 end
  318.             end)
  319.         end
  320.     end
  321.  
  322.     if room:FindFirstChild("SavePoint") then
  323.         local SP = ZPModule.new(room.SavePoint)
  324.         local TEXTO = nil
  325.         local conn = nil
  326.         SP.playerEntered:Connect(function(plyr: Player)
  327.             if plyr == plr then
  328.                 local inside = true
  329.  
  330.                 conn = SP.playerExited:Connect(function(plyr: Player)
  331.                     if plyr == plr then
  332.                         inside = false
  333.                         if TEXTO then
  334.                             TEXTO:Destroy()
  335.                             TEXTO = nil
  336.                         end
  337.                         conn:Disconnect()
  338.                     end
  339.                 end)
  340.  
  341.                 if TEXTO == nil then
  342.                     TEXTO = script.RandomText:Clone()
  343.                     TEXTO.Text = "Press W to Save"
  344.                     TEXTO.Parent = plr.PlayerGui.Interface
  345.                 end
  346.  
  347.                 waitForInputType(Enum.KeyCode.W)
  348.                 if inside then
  349.                     char.Data.SavePoint.Value = char.Data.Room.Value
  350.                     char.Data.Mana.Value = 100
  351.  
  352.                     local roomChangeTable = {}
  353.                     for i, v in pairs(char.Data.RoomData:GetChildren()) do
  354.                         table.insert(roomChangeTable, v.Name)
  355.                     end
  356.                     local datatoSave = {}
  357.                     for i, v in pairs(char.Data:GetChildren()) do
  358.                         if plr.Data:FindFirstChild(v.Name) and not v:IsA("Folder") then
  359.                             datatoSave[v.Name] = v.Value
  360.                         end
  361.                     end
  362.  
  363.                     remots.RemoteEvent:FireServer("Save", datatoSave, roomChangeTable)
  364.                     char.Data.Lives.Value = char.Data.MaxLives.Value
  365.  
  366.                     if TEXTO ~= nil then
  367.                         TEXTO.Text = "SAVED"
  368.                         wait(1)
  369.                         if TEXTO ~= nil then
  370.                             TEXTO:Destroy()
  371.                             TEXTO = nil
  372.                         end
  373.                     end
  374.                 end
  375.             end
  376.         end)
  377.     end
  378.  
  379.     if room:FindFirstChild("Background") then
  380.         for i, v in pairs(room.Background:GetChildren()) do
  381.             if v:IsA("Sound") then
  382.                 v:Play()
  383.             end
  384.         end
  385.     end
  386.  
  387.     if room:FindFirstChild("Enemies") then
  388.         for i, v in pairs(room.Enemies:GetChildren()) do
  389.             if v:FindFirstChild("Data") and v.Data:FindFirstChild("AIType") then
  390.                 AIModule.Create(v.Data.AIType.Value, v, plr)
  391.             end
  392.         end
  393.     end
  394.  
  395.     char.HumanoidRootPart.Anchored = false
  396.     game.TweenService:Create(plr.PlayerGui.Interface.Fade, TweenInfo.new(.15), {BackgroundTransparency = 1}):Play()
  397. end
  398.  
  399. for i, v in pairs(char:GetDescendants()) do
  400.     if v:IsA("BasePart") and v.Name ~= "HumanoidRootPart" then
  401.         v.Massless = true
  402.     end
  403. end
  404.  
  405. if plr.Data.SavePoint.Value == "" then
  406.     roomLoad("KP1", true)
  407. else
  408.     roomLoad(plr.Data.SavePoint.Value, true)
  409. end
  410.  
  411. -------------------------------------------------------------------              EVERYTHING LOADED
  412. repeat task.wait() until data.Room.Value ~= ""
  413. script.WalkingSounds.Parent = char.HumanoidRootPart
  414.  
  415. local function PlayWalkingSound(state, name)
  416.     if state == true then
  417.         for i, v in pairs(char.HumanoidRootPart.WalkingSounds:GetChildren()) do
  418.             if v.Name == name  then
  419.                 if v.Playing == false then
  420.                     v.Playing = true
  421.                 end
  422.             else
  423.                 v.Playing = false
  424.  
  425.             end
  426.         end
  427.     else
  428.         for i, v in pairs(char.HumanoidRootPart.WalkingSounds:GetChildren()) do
  429.             v.Playing = false
  430.         end
  431.     end
  432. end
  433.  
  434. local function ResetVelocity()
  435.     char.HumanoidRootPart.AssemblyLinearVelocity *= Vector3.new(0,0,0)
  436.     if char.HumanoidRootPart:FindFirstChild("Dash") then char.HumanoidRootPart:FindFirstChild("Dash"):Destroy() end
  437.     if char.HumanoidRootPart:FindFirstChild("Pogo") then char.HumanoidRootPart:FindFirstChild("Pogo"):Destroy() end
  438.     if char.HumanoidRootPart:FindFirstChild("PlayerPush") then char.HumanoidRootPart:FindFirstChild("PlayerPush"):Destroy() end
  439.     if char.HumanoidRootPart:FindFirstChild("JumpForce") then char.HumanoidRootPart:FindFirstChild("JumpForce"):Destroy() end
  440.     if char.HumanoidRootPart:FindFirstChild("2XJump") then char.HumanoidRootPart:FindFirstChild("2XJump"):Destroy() end
  441. end
  442.  
  443. function createForce(name, att, force)
  444.     local vectorForce = Instance.new("VectorForce")
  445.     vectorForce.Attachment0 = att
  446.     vectorForce.Name = name
  447.     vectorForce.RelativeTo = Enum.ActuatorRelativeTo.Attachment0
  448.     vectorForce.Force = att.CF * workspace.Gravity * char.HumanoidRootPart:GetMass() * force
  449.     vectorForce.ApplyAtCenterOfMass = true
  450.     vectorForce.Parent = char.HumanoidRootPart
  451.     return vectorForce
  452. end
  453.  
  454. local LastMDirection = Vector3.new()
  455.  
  456. local right = false
  457. local left = false
  458. local up = false
  459. local down = false
  460. local dashcd = false
  461. local slashcd = false
  462. local canNotDoAnything = false
  463. local jumps = 2
  464. local sliding = false
  465. local slidingDir = "left"
  466.  
  467.  
  468. UIS.InputBegan:Connect(function(input, isTyping)
  469.     if isTyping then return end
  470.     local PCKeys = string.split(plr.Data.PCControls.Value, "_RAMS_")
  471.    
  472.     if input.KeyCode == Enum.KeyCode.Thumbstick1 then
  473.         print("Left", input.Delta.X)
  474.     end
  475.  
  476.     if input.KeyCode == Enum.KeyCode.D then
  477.         right = true
  478.         LastMDirection = Vector3.new(0,0,-1)
  479.     elseif input.KeyCode == Enum.KeyCode.A then
  480.         left = true
  481.         LastMDirection = Vector3.new(0,0,1)
  482.     elseif input.KeyCode == Enum.KeyCode.S then
  483.         down = true
  484.     elseif input.KeyCode == Enum.KeyCode.W then
  485.         up = true
  486.     elseif input.KeyCode == Enum.KeyCode[PCKeys[7]] then
  487.         plr.PlayerGui.Interface.Inventory.Visible = not plr.PlayerGui.Interface.Inventory.Visible
  488.     elseif input.KeyCode == Enum.KeyCode[PCKeys[4]] then
  489.         if canNotDoAnything or char.Data.Mana.Value < 33 then return end
  490.         local inputDown = true
  491.         local sound = nil
  492.         local conn = nil
  493.         conn = UIS.InputEnded:Connect(function(input2, isTyping)
  494.             if input2.KeyCode == Enum.KeyCode[PCKeys[4]] then
  495.                 inputDown = false
  496.                 if sound then
  497.                     sound:Destroy()
  498.                 end
  499.                 canNotDoAnything = false
  500.                 conn:Disconnect()
  501.             end
  502.         end)
  503.  
  504.         task.delay(.25, function()
  505.             if inputDown == false then
  506.                 if char.Data.Mana.Value >= 33 then
  507.                     if up then
  508.                         if char.Data.WSpell.Value >= 1 then
  509.                             char.Humanoid.WalkSpeed = 16
  510.                             char.Data.Mana.Value -= 33
  511.                             print("SHRIEK")
  512.                         end
  513.                     elseif down and char.Humanoid:GetState() == Enum.HumanoidStateType.Freefall then
  514.                         if char.Data.SSpell.Value >= 1 then
  515.                             char.Humanoid.WalkSpeed = 16
  516.                             char.Data.Mana.Value -= 33
  517.                             print("Smash")
  518.                         end
  519.                     elseif LastMDirection == Vector3.new(0,0,-1) or LastMDirection == Vector3.new(0,0,1) then
  520.                         if char.Data.ADSpell.Value >= 1 then
  521.                             char.Humanoid.WalkSpeed = 16
  522.                             char.Data.Mana.Value -= 33
  523.                             print("FIREBALL")
  524.                         end
  525.                     end
  526.  
  527.                 end
  528.             else
  529.                 if char.Data.Mana.Value >= 33 and char.Data.Lives.Value < char.Data.MaxLives.Value then
  530.  
  531.                     local soundo = game.ReplicatedStorage.Sounds.Charge:Clone()
  532.                     sound = soundo
  533.                     soundo.Parent = char.Head
  534.                     soundo:Play()
  535.                     game.Debris:AddItem(soundo, soundo.TimeLength +1)
  536.                     char.Humanoid.WalkSpeed = 0
  537.                     canNotDoAnything = true
  538.                 end
  539.             end
  540.         end)
  541.         task.delay(1.141, function()
  542.             if inputDown == true then
  543.                 if char.Data.Mana.Value >= 33 then
  544.                     local soundo = game.ReplicatedStorage.Sounds:FindFirstChild("Heal"):Clone()
  545.                     soundo.Parent = char.Head
  546.                     soundo:Play()
  547.                     game.Debris:AddItem(soundo, soundo.TimeLength +1)
  548.                     char.Data.Mana.Value -= 33
  549.                     char.Data.Lives.Value = math.clamp(char.Data.Lives.Value+1, 1, char.Data.MaxLives.Value)
  550.                     while inputDown and char.Data.Mana.Value >= 33 and char.Data.Lives.Value < char.Data.MaxLives.Value do
  551.                         task.wait(.891)
  552.                         if inputDown and char.Data.Mana.Value >= 33 and char.Data.Lives.Value < char.Data.MaxLives.Value then
  553.                             local soundo = game.ReplicatedStorage.Sounds:FindFirstChild("Heal"):Clone()
  554.                             soundo.Parent = char.Head
  555.                             soundo:Play()
  556.                             game.Debris:AddItem(soundo, soundo.TimeLength +1)
  557.                             char.Data.Mana.Value -= 33
  558.                             char.Data.Lives.Value = math.clamp(char.Data.Lives.Value+1, 1, char.Data.MaxLives.Value)
  559.                         end
  560.                     end
  561.                     if sound then
  562.                         sound:Destroy()
  563.                     end
  564.                     char.Humanoid.WalkSpeed = 16
  565.                 end
  566.             else
  567.  
  568.                 char.Humanoid.WalkSpeed = 16
  569.             end
  570.             canNotDoAnything = false
  571.         end)
  572.  
  573.     elseif input.KeyCode == Enum.KeyCode[PCKeys[3]] then
  574.         if canNotDoAnything then return end
  575.  
  576.         if char.Data.Dash.Value >= 1 then
  577.             if not dashcd then
  578.                 dashcd = true
  579.                 ResetVelocity()
  580.  
  581.                 local animo = char.Humanoid:LoadAnimation(game.ReplicatedStorage.Animations.Player.Dash)
  582.                 animo:Play()
  583.                 local bv = Instance.new("BodyVelocity")
  584.                 bv.MaxForce = Vector3.new(99999,10000,99999)
  585.                 local pos = -55
  586.                 if LastMDirection == Vector3.new(0,0,1) then
  587.                     pos = 55
  588.                 end
  589.                 bv.Velocity = Vector3.new(0,0,pos)
  590.                 bv.Name = "Dash"
  591.                 bv.Parent = char.HumanoidRootPart
  592.  
  593.                 local soundo = game.ReplicatedStorage.Sounds:FindFirstChild("Dash"):Clone()
  594.                 soundo.Parent = char.Head
  595.                 soundo:Play()
  596.                 game.Debris:AddItem(soundo, soundo.TimeLength +1)
  597.  
  598.                 game.Debris:AddItem(bv, .2)
  599.                 task.delay(.2, function()
  600.                     animo:Stop()
  601.                     animo:Destroy()
  602.                 end)
  603.                 if char.Humanoid:GetState() ~= Enum.HumanoidStateType.Freefall then
  604.                     task.delay(.72, function()
  605.                         dashcd = false
  606.                     end)
  607.                 end
  608.             end
  609.         end
  610.     elseif input.KeyCode == Enum.KeyCode[PCKeys[5]] then
  611.         if canNotDoAnything then return end
  612.  
  613.         local inputDown = true
  614.         local soundo = game.ReplicatedStorage.Sounds.SuperDashCharge:Clone()
  615.         soundo.Parent = char.Head
  616.         soundo:Play()
  617.         game.Debris:AddItem(soundo, soundo.TimeLength +1)
  618.         char.Humanoid.WalkSpeed = 0
  619.         canNotDoAnything = true
  620.         local conn = nil
  621.         conn = UIS.InputEnded:Connect(function(input2, isTyping)
  622.             if input2.KeyCode == Enum.KeyCode[PCKeys[5]] then
  623.                 inputDown = false
  624.                 if soundo then
  625.                     soundo:Destroy()
  626.                 end
  627.                 canNotDoAnything = false
  628.                 char.Humanoid.WalkSpeed = 16
  629.                 char.HumanoidRootPart.Anchored = false
  630.                 conn:Disconnect()
  631.             end
  632.         end)
  633.  
  634.         if sliding == true and char.Humanoid:GetState() == Enum.HumanoidStateType.Freefall then
  635.             char.Humanoid.WalkSpeed = 0
  636.             char.HumanoidRootPart.Anchored = true
  637.             char.HumanoidRootPart.AssemblyLinearVelocity *= Vector3.new(0,0,0)
  638.  
  639.             task.delay(0.8, function()
  640.                 if inputDown == true then
  641.                     conn:Disconnect()
  642.                     local soundor = game.ReplicatedStorage.Sounds.SuperDashReady:Clone()
  643.                     soundor.Parent = char.Head
  644.                     soundor:Play()
  645.                     game.Debris:AddItem(soundor, soundor.TimeLength+1)
  646.                     while true do
  647.                         local input, processed = UIS.InputEnded:Wait()
  648.                         if processed then continue end
  649.                         if input.KeyCode == Enum.KeyCode[PCKeys[5]] then break end
  650.                     end
  651.                     local soundor = game.ReplicatedStorage.Sounds.SuperDashBurst:Clone()
  652.                     soundor.Parent = char.Head
  653.                     soundor:Play()
  654.                     game.Debris:AddItem(soundor, soundor.TimeLength+1)
  655.  
  656.                     local dashLoop = game.ReplicatedStorage.Sounds.SuperDashLoop:Clone()
  657.                     dashLoop.Parent = char.Head
  658.                     dashLoop:Play()
  659.  
  660.                     char.HumanoidRootPart.Anchored = false
  661.                     local bv = Instance.new("BodyVelocity")
  662.                     bv.MaxForce = Vector3.new(99999,10000,99999)
  663.                     local pos = -66
  664.                     if LastMDirection == Vector3.new(0,0,1) then
  665.                         pos = 66
  666.                     end
  667.                     bv.Velocity = Vector3.new(0,0,pos)
  668.                     bv.Name = "Dash"
  669.                     bv.Parent = char.HumanoidRootPart
  670.                     char.Humanoid.WalkSpeed = 16
  671.                     local stop = false
  672.                     spawn(function()
  673.                         while true do
  674.                             local Ray = Ray.new(char.HumanoidRootPart.Position, char.HumanoidRootPart.CFrame.LookVector*3)
  675.                             --DrawRay(char.HumanoidRootPart.Position, char.HumanoidRootPart.CFrame.LookVector*3)
  676.                             local Wall, HitPosition, Normal, Material = workspace:FindPartOnRayWithWhitelist(Ray, {workspace.Render.MapHitbox})
  677.                             if Wall then -- If wall is in front of you
  678.                                 stop = true
  679.                                 local soundor = game.ReplicatedStorage.Sounds.SuperDashHitWall:Clone()
  680.                                 soundor.Parent = char.Head
  681.                                 soundor:Play()
  682.                                 game.Debris:AddItem(soundor, soundor.TimeLength+1)
  683.                                 break
  684.                             end
  685.                             task.wait()
  686.                         end
  687.                     end)
  688.                     spawn(function()
  689.                         while true do
  690.                             local input, processed = UIS.InputBegan:Wait()
  691.                             if processed then continue end
  692.                             if input.KeyCode == Enum.KeyCode.A or input.KeyCode == Enum.KeyCode.D then
  693.                                 stop = true
  694.                                 local soundor = game.ReplicatedStorage.Sounds.SuperDashAirBrake:Clone()
  695.                                 soundor.Parent = char.Head
  696.                                 soundor:Play()
  697.                                 game.Debris:AddItem(soundor, soundor.TimeLength+1)
  698.                                 break
  699.                             end
  700.                         end
  701.                     end)
  702.  
  703.                     repeat task.wait() until stop == true
  704.                     dashLoop:Destroy()
  705.                     bv:Destroy()
  706.                     if soundo then
  707.                         soundo:Destroy()
  708.                     end
  709.                     canNotDoAnything = false
  710.                     char.Humanoid.WalkSpeed = 16
  711.                     char.HumanoidRootPart.Anchored = false
  712.                 else
  713.                     char.Humanoid.WalkSpeed = 16
  714.                 end
  715.             end)
  716.         elseif sliding == false and char.Humanoid:GetState() ~= Enum.HumanoidStateType.Freefall then
  717.             char.Humanoid.WalkSpeed = 0
  718.             task.delay(0.8, function()
  719.                 if inputDown == true then
  720.                     conn:Disconnect()
  721.  
  722.                     local soundor = game.ReplicatedStorage.Sounds.SuperDashReady:Clone()
  723.                     soundor.Parent = char.Head
  724.                     soundor:Play()
  725.                     game.Debris:AddItem(soundor, soundor.TimeLength+1)
  726.  
  727.                     while true do
  728.                         local input, processed = UIS.InputEnded:Wait()
  729.                         if processed then continue end
  730.                         if input.KeyCode == Enum.KeyCode[PCKeys[5]] then break end
  731.                     end
  732.  
  733.                     local soundor = game.ReplicatedStorage.Sounds.SuperDashBurst:Clone()
  734.                     soundor.Parent = char.Head
  735.                     soundor:Play()
  736.                     game.Debris:AddItem(soundor, soundor.TimeLength+1)
  737.  
  738.                     local dashLoop = game.ReplicatedStorage.Sounds.SuperDashLoop:Clone()
  739.                     dashLoop.Parent = char.Head
  740.                     dashLoop:Play()
  741.  
  742.                     local bv = Instance.new("BodyVelocity")
  743.                     bv.MaxForce = Vector3.new(99999,10000,99999)
  744.                     local pos = -66
  745.                     if LastMDirection == Vector3.new(0,0,1) then
  746.                         pos = 66
  747.                     end
  748.                     bv.Velocity = Vector3.new(0,0,pos)
  749.                     bv.Name = "Dash"
  750.                     bv.Parent = char.HumanoidRootPart
  751.                     char.Humanoid.WalkSpeed = 16
  752.                     local stop = false
  753.                     spawn(function()
  754.                         while true do
  755.                             local Ray = Ray.new(char.HumanoidRootPart.Position, char.HumanoidRootPart.CFrame.LookVector*3)
  756.                             --DrawRay(char.HumanoidRootPart.Position, char.HumanoidRootPart.CFrame.LookVector*3)
  757.                             local Wall, HitPosition, Normal, Material = workspace:FindPartOnRayWithWhitelist(Ray, {workspace.Render.MapHitbox})
  758.                             if Wall then -- If wall is in front of you
  759.                                 stop = true
  760.                                 local soundor = game.ReplicatedStorage.Sounds.SuperDashHitWall:Clone()
  761.                                 soundor.Parent = char.Head
  762.                                 soundor:Play()
  763.                                 game.Debris:AddItem(soundor, soundor.TimeLength+1)
  764.                                 break
  765.                             end
  766.                             task.wait()
  767.                         end
  768.                     end)
  769.                     spawn(function()
  770.                         while true do
  771.                             local input, processed = UIS.InputBegan:Wait()
  772.                             if processed then continue end
  773.                             if input.KeyCode == Enum.KeyCode.A or input.KeyCode == Enum.KeyCode.D then
  774.                                 stop = true
  775.                                 local soundor = game.ReplicatedStorage.Sounds.SuperDashAirBrake:Clone()
  776.                                 soundor.Parent = char.Head
  777.                                 soundor:Play()
  778.                                 game.Debris:AddItem(soundor, soundor.TimeLength+1)
  779.                                 break
  780.                             end
  781.                         end
  782.                     end)
  783.  
  784.                     repeat task.wait() until stop == true
  785.                     dashLoop:Destroy()
  786.                     bv:Destroy()
  787.                     if soundo then
  788.                         soundo:Destroy()
  789.                     end
  790.                     canNotDoAnything = false
  791.                     char.Humanoid.WalkSpeed = 16
  792.                     char.HumanoidRootPart.Anchored = false
  793.                 else
  794.                     char.Humanoid.WalkSpeed = 16
  795.                 end
  796.             end)
  797.         end
  798.  
  799.     elseif input.KeyCode == Enum.KeyCode[PCKeys[1]] then   
  800.         if canNotDoAnything then return end
  801.         if sliding then
  802.             ResetVelocity()
  803.  
  804.             effects.Show("PlaySoundPart", char.Head.Position, game.ReplicatedStorage.Sounds.WallJump)
  805.             local bv = Instance.new("BodyVelocity")
  806.             bv.MaxForce = Vector3.new(0,99999,99999)
  807.             bv.Velocity = (char.HumanoidRootPart.CFrame.UpVector * 30) + (char.HumanoidRootPart.CFrame.LookVector * -25) -- You can change the multiplicator value
  808.             bv.Name = "JumpForce"
  809.             bv.Parent = char.HumanoidRootPart
  810.  
  811.             game.Debris:AddItem(bv, .3)
  812.             task.delay(.1, function()
  813.                 if slidingDir == "left" and left == true then
  814.                     ResetVelocity()
  815.                     bv:Destroy()
  816.                     char.HumanoidRootPart.AssemblyLinearVelocity = Vector3.new(0,30,5)
  817.                 elseif slidingDir == "right" and right == true then
  818.                     ResetVelocity()
  819.                     bv:Destroy()
  820.                     char.HumanoidRootPart.AssemblyLinearVelocity = Vector3.new(0,30,-5)
  821.                 end
  822.             end)
  823.             jumps = 1
  824.         else
  825.             if char.Humanoid:GetState() ~= Enum.HumanoidStateType.Freefall then
  826.                 effects.Show("PlaySoundPart", char.Head.Position, game.ReplicatedStorage.Sounds.Jump)
  827.                 ResetVelocity()
  828.  
  829.                 local bv = Instance.new("BodyVelocity")
  830.                 bv.MaxForce = Vector3.new(0,99999,0)
  831.                 bv.Velocity = char.HumanoidRootPart.CFrame.UpVector * 30 -- You can change the multiplicator value
  832.                 bv.Name = "JumpForce"
  833.                 bv.Parent = char.HumanoidRootPart
  834.                 jumps = 1
  835.  
  836.                 game.Debris:AddItem(bv, .3)
  837.             else
  838.                 if char.Data.DoubleJump.Value >= 1 then
  839.                     if jumps >= 1 then
  840.                         jumps = 0
  841.                         effects.Show("PlaySoundPart", char.Head.Position, game.ReplicatedStorage.Sounds.DoubleJump)
  842.                         ResetVelocity()
  843.  
  844.                         local bv = Instance.new("BodyVelocity")
  845.                         bv.MaxForce = Vector3.new(0,99999,0)
  846.                         bv.Velocity = char.HumanoidRootPart.CFrame.UpVector * 30 -- You can change the multiplicator value
  847.                         bv.Name = "2XJump"
  848.                         bv.Parent = char.HumanoidRootPart
  849.  
  850.                         game.Debris:AddItem(bv, .3)
  851.                     end
  852.                 end
  853.             end
  854.         end
  855.     elseif input.KeyCode == Enum.KeyCode[PCKeys[2]] then
  856.         if canNotDoAnything then return end
  857.  
  858.         if not slashcd then
  859.             slashcd = true
  860.             local op = OverlapParams.new()
  861.             op.FilterType = Enum.RaycastFilterType.Exclude
  862.             op.FilterDescendantsInstances = char:GetDescendants()
  863.  
  864.             local hits = {}
  865.             local pos
  866.             local size = Vector3.new(5,5.5,6.8)
  867.             local dir = ""
  868.             if up then
  869.                 dir = "up"
  870.                 size = Vector3.new(8,5.5,10)
  871.                 pos = CFrame.new(char.HumanoidRootPart.Position + Vector3.new(0,5,0), char.HumanoidRootPart.Position + Vector3.new(0,6,0)) * CFrame.Angles(0,0,0)
  872.             elseif down and char.Humanoid:GetState() == Enum.HumanoidStateType.Freefall then
  873.                 dir = "down"
  874.                 size = Vector3.new(8,5.5,11)
  875.                 pos = CFrame.new(char.HumanoidRootPart.Position + Vector3.new(0,-5,0), char.HumanoidRootPart.Position + Vector3.new(0,-6,0)) * CFrame.Angles(0,0,0)
  876.             elseif LastMDirection == Vector3.new(0,0,-1) then
  877.                 dir = "right"
  878.                 pos = CFrame.new(char.HumanoidRootPart.Position + Vector3.new(0,0,-5), char.HumanoidRootPart.Position) * CFrame.Angles(0,0,0)
  879.                 char.Humanoid:LoadAnimation(game.ReplicatedStorage.Animations.Player.SlashRight):Play()
  880.             else
  881.                 dir = "left"
  882.                 pos = CFrame.new(char.HumanoidRootPart.Position + Vector3.new(0,0,5), char.HumanoidRootPart.Position) * CFrame.Angles(0,0,0)
  883.                 char.Humanoid:LoadAnimation(game.ReplicatedStorage.Animations.Player.SlashRight):Play()
  884.  
  885.             end
  886.             task.delay(0.2,function()
  887.                 effects.Show("Slash", dir, char)
  888.             end)
  889.             local hitbox = workspace:GetPartBoundsInBox(pos, size, op)
  890.  
  891.             --showbox.Show(size, pos, .75)
  892.  
  893.             local canPogo = false
  894.             for _, v in pairs(hitbox) do
  895.                 if v.Name == "Hitbox" and not table.find(hits,v.Parent) then
  896.                     table.insert(hits, v.Parent)
  897.                     --local hit = RS.hit:Clone()
  898.                     --hit.TextLabel.Text = "Hit"
  899.                     --hit.Adornee = v
  900.                     --hit.TextLabel.Position = UDim2.new(math.random(0,50)/100,0,math.random(0,82)/100,0)
  901.                     --hit.Parent = v
  902.                     --game.Debris:AddItem(hit, 1.25)
  903.                     if not v.Parent.Data:FindFirstChild("NOKNOCK") then
  904.                         canPogo = true
  905.                     end
  906.                     if not v.Parent.Data:FindFirstChild("IFRAME") then
  907.                         if v.Parent.Data:FindFirstChild("ObjectHits") then
  908.                             if v.Parent.Data.ObjectHits.Value > 1 then
  909.                                 v.Parent.Data.ObjectHits.Value -= 1
  910.                                 if v.Parent.Data:FindFirstChild("DamageSound") then
  911.                                     local splitString = string.split(v.Parent.Data:FindFirstChild("DamageSound").Value, ":")
  912.                                     if #splitString > 1 then
  913.                                         effects.Show("PlaySoundPart", v.Position, game.ReplicatedStorage.Sounds:FindFirstChild(splitString[math.random(#splitString)]))
  914.                                     else
  915.                                         effects.Show("PlaySoundPart", v.Position, game.ReplicatedStorage.Sounds:FindFirstChild(splitString[1]))
  916.                                     end
  917.                                 end
  918.                                 if v.Parent.Name == "GeoRock" then
  919.                                     effects.Show("ExplodeMoney", v.CFrame * CFrame.Angles(0,0,0), math.random(1,2), plr)
  920.                                 end
  921.                             else
  922.                                 if v.Parent.Data:FindFirstChild("Save") then
  923.                                     local change = Instance.new("StringValue")
  924.                                     change.Name = v.Parent.Data.Save.Value
  925.                                     change.Parent = char.Data.RoomData
  926.                                 end
  927.                                 if v.Parent.Data:FindFirstChild("DeathSound") then
  928.                                     local splitString = string.split(v.Parent.Data:FindFirstChild("DeathSound").Value, ":")
  929.                                     if #splitString > 1 then
  930.                                         effects.Show("PlaySoundPart", v.Position, game.ReplicatedStorage.Sounds:FindFirstChild(splitString[math.random(#splitString)]))
  931.                                     else
  932.                                         effects.Show("PlaySoundPart", v.Position, game.ReplicatedStorage.Sounds:FindFirstChild(splitString[1]))
  933.                                     end
  934.                                 end
  935.                                 if v.Parent.Data:FindFirstChild("RandomDropMoney") then
  936.                                     effects.Show("ExplodeMoney", v.CFrame * CFrame.Angles(0,0,0), math.random(1,25), plr)
  937.                                 end
  938.                                 v.Parent:Destroy()
  939.                             end
  940.                         else
  941.                             char.Data.Mana.Value = math.clamp(char.Data.Mana.Value + 11, 0, 100)
  942.                             if v.Parent.Data.Lives.Value > char.Data.Damage.Value then
  943.                                 v.Parent.Data.Lives.Value -= char.Data.Damage.Value
  944.  
  945.                                 if not v.Parent.Data:FindFirstChild("UNKNOCK") then
  946.                                     local bv = Instance.new("BodyVelocity",v.Parent.HumanoidRootPart)
  947.                                     bv.MaxForce = Vector3.new(99999,99999,99999)
  948.                                     bv.Name = "EnemyPush"
  949.                                     bv.P = 10
  950.                                     bv.Velocity = CFrame.new(v.Parent.HumanoidRootPart.Position, char.HumanoidRootPart.Position).LookVector * -15
  951.                                     game.Debris:AddItem(bv,.2)
  952.                                 end
  953.  
  954.                                 effects.Show("PlaySoundPart", v.Position, game.ReplicatedStorage.Sounds.EnemyDamage)
  955.                             else
  956.                                 effects.Show("PlaySoundPart", v.Position, game.ReplicatedStorage.Sounds.EnemyDeath)
  957.  
  958.                                 if  v.Parent.Data:FindFirstChild("DropMoney") then
  959.                                     effects.Show("ExplodeMoney", v.CFrame * CFrame.Angles(0,0,0), v.Parent.Data.DropMoney.Value, plr)
  960.                                 end
  961.                                 v.Parent:Destroy()
  962.                             end
  963.                         end
  964.                     end
  965.                 end
  966.             end
  967.             if #hits > 0  and dir ~= "up" and canPogo == true then
  968.                 ResetVelocity()
  969.                 jumps = 1
  970.                 dashcd = false
  971.                 local bv = Instance.new("BodyVelocity")
  972.                 bv.MaxForce = Vector3.new(99999,0,99999)
  973.                 bv.Name = "Pogo"
  974.                 bv.P = 10
  975.                 bv.Parent = char.HumanoidRootPart
  976.  
  977.                 if dir == "down" then
  978.                     bv.MaxForce = Vector3.new(0,99999,0)
  979.                     bv.Velocity = char.HumanoidRootPart.CFrame.UpVector * 17
  980.                     game.Debris:AddItem(bv,.2)
  981.                 else
  982.                     bv.Velocity = char.HumanoidRootPart.CFrame.LookVector * -15
  983.                     game.Debris:AddItem(bv,.2)
  984.                 end
  985.             end
  986.             task.delay(.42, function()
  987.                 slashcd = false
  988.             end)
  989.         end
  990.     end
  991. end)
  992.  
  993. UIS.InputEnded:Connect(function(input, isTyping)
  994.     if isTyping then return end
  995.     local PCKeys = string.split(plr.Data.PCControls.Value, "_RAMS_")
  996.  
  997.     if input.KeyCode == Enum.KeyCode.D then
  998.         right = false
  999.     elseif input.KeyCode == Enum.KeyCode.A then
  1000.         left = false
  1001.     elseif input.KeyCode == Enum.KeyCode.S then
  1002.         down = false
  1003.     elseif input.KeyCode == Enum.KeyCode.W then
  1004.         up = false
  1005.     elseif input.KeyCode == Enum.KeyCode[PCKeys[1]] then
  1006.         if char.HumanoidRootPart:FindFirstChild("JumpForce") then char.HumanoidRootPart:FindFirstChild("JumpForce"):Destroy() end
  1007.         if char.HumanoidRootPart:FindFirstChild("2XJump") then char.HumanoidRootPart:FindFirstChild("2XJump"):Destroy() end
  1008.     end
  1009. end)
  1010.  
  1011.  
  1012. char.Humanoid.StateChanged:Connect(function(_, state)
  1013.     if state == Enum.HumanoidStateType.Landed then
  1014.         if  char.Head:FindFirstChild("Fall") then
  1015.             char.Head:FindFirstChild("Fall"):Destroy()
  1016.         end
  1017.  
  1018.         char.Humanoid:LoadAnimation(game.ReplicatedStorage.Animations.Player.Land):Play()
  1019.        
  1020.         local Ray = Ray.new(char.HumanoidRootPart.Position, char.HumanoidRootPart.CFrame.UpVector * -3)
  1021.         --DrawRay(char.HumanoidRootPart.Position, char.HumanoidRootPart.CFrame.LookVector*3)
  1022.         local Wall, HitPosition, Normal, Material = workspace:FindPartOnRayWithWhitelist(Ray, {workspace.Render.MapHitbox})
  1023.         if Wall then -- If wall is in front of you
  1024.             if Wall:FindFirstChild("LandSound") then
  1025.                 effects.Show("PlaySoundPart", char.Head.Position, game.ReplicatedStorage.Sounds:FindFirstChild(Wall.LandSound.Value))
  1026.  
  1027.             else
  1028.                 effects.Show("PlaySoundPart", char.Head.Position, game.ReplicatedStorage.Sounds.LandSoft)
  1029.             end
  1030.         else
  1031.             effects.Show("PlaySoundPart", char.Head.Position, game.ReplicatedStorage.Sounds.LandSoft)
  1032.         end
  1033.         jumps = 2 -- change to 1 for upgradeable
  1034.         dashcd = false
  1035.     elseif state == Enum.HumanoidStateType.Freefall then
  1036.         if not char.Head:FindFirstChild("Fall") then
  1037.             local wss = game.ReplicatedStorage.Sounds.Fall:Clone()
  1038.             wss.Parent = char.Head
  1039.             wss:Play()
  1040.         end
  1041.     end
  1042. end)
  1043.  
  1044. local function updateLifeBar()
  1045.     for i, v in pairs(plr.PlayerGui.Interface.Lives:GetChildren()) do
  1046.         if v:IsA("Frame") then
  1047.             v:Destroy()
  1048.         end
  1049.     end
  1050.  
  1051.     for i = 1, char.Data.Lives.Value do
  1052.         local LIFER = script.Life:Clone()
  1053.         LIFER.Parent = plr.PlayerGui.Interface.Lives
  1054.     end
  1055.     if char.Data.Lives.Value ~= char.Data.MaxLives.Value then
  1056.         for i = 1, char.Data.MaxLives.Value - char.Data.Lives.Value do
  1057.             local LIFER = script.Life:Clone()
  1058.             LIFER.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
  1059.             LIFER.Parent = plr.PlayerGui.Interface.Lives
  1060.         end
  1061.     end
  1062. end
  1063. updateLifeBar()
  1064.  
  1065. char.Data.MaxLives.Changed:Connect(function()
  1066.     updateLifeBar()
  1067. end)
  1068. local NOWLIVES = char.Data.Lives.Value
  1069. char.Data.Lives.Changed:Connect(function()
  1070.     updateLifeBar()
  1071.  
  1072.     if char.Data.Lives.Value < NOWLIVES then
  1073.         if NOWLIVES - char.Data.Lives.Value == 1 then
  1074.             effects.Show("PlaySoundPart", char.Head.Position, game.ReplicatedStorage.Sounds.DamageSelf)
  1075.         else
  1076.             effects.Show("PlaySoundPart", char.Head.Position, game.ReplicatedStorage.Sounds.DamageSelf):FindFirstChildOfClass("Sound").Volume = 1.2
  1077.         end
  1078.     end
  1079.     NOWLIVES = char.Data.Lives.Value
  1080.  
  1081.     if char.Data.Lives.Value <= 0 then
  1082.         char.PrimaryPart.Anchored = true
  1083.         char.Humanoid:LoadAnimation(game.ReplicatedStorage.Animations.Player.Death):Play()
  1084.         task.wait(0.05)
  1085.         local pxplode = script.DeathPlode:Clone()
  1086.         pxplode.Position = char.PrimaryPart.Position
  1087.         pxplode.Parent = workspace
  1088.         game.TweenService:Create(pxplode, TweenInfo.new(.7), {Size = Vector3.new(50,50,50)}):Play()
  1089.         game.Debris:AddItem(pxplode, 1)
  1090.         wait(1)
  1091.         if plr.Data.SavePoint.Value ~= "" then
  1092.             roomLoad(plr.Data.SavePoint.Value, true)
  1093.         else
  1094.             roomLoad("KP1", true)
  1095.         end
  1096.  
  1097.     end
  1098. end)
  1099.  
  1100. local function DrawRay(origin: Vector3, direction: Vector3)
  1101.  
  1102.     local part = Instance.new("Part")
  1103.     part.Name = "Ray"
  1104.     part.Anchored = true
  1105.  
  1106.     local result = workspace:Raycast(origin, direction)
  1107.  
  1108.     local len = (origin - (origin + direction)).Magnitude
  1109.     if result then
  1110.         len = (origin - result.Position).Magnitude
  1111.     end
  1112.  
  1113.     part.Size = Vector3.new(1, 1 , len)
  1114.     part.Material = Enum.Material.SmoothPlastic
  1115.     part.Color = Color3.new(255,255,255)
  1116.     part.Transparency = .5
  1117.     part.CanCollide = false
  1118.     part.CanTouch = false
  1119.     part.CFrame = CFrame.new(origin, direction) * CFrame.new(0, 0, -len*0.5)
  1120.  
  1121.     part.Parent = workspace
  1122.  
  1123.     return part
  1124. end
  1125.  
  1126. local actionTableDisable = {
  1127.     "jumpAction";
  1128.     "moveForwardAction";
  1129.     "moveBackwardAction";
  1130. }
  1131.  
  1132. local animation = char.Humanoid:LoadAnimation(game.ReplicatedStorage.Animations.Player.Idle)
  1133. while task.wait() do
  1134.     char.Data.Damage.Value = 5 + (4*char.Data.DamageUpgrade.Value)
  1135.     plr.PlayerGui.Interface.Money.Text = char.Data.Money.Value
  1136.     plr.PlayerGui.Interface.Mana.Inside.Size = UDim2.new(1,0,char.Data.Mana.Value/100,0)
  1137.     if char then
  1138.         for i, v in pairs(game.ContextActionService:GetAllBoundActionInfo()) do
  1139.             if table.find(actionTableDisable, tostring(i)) then
  1140.                 print(i.." been unbinded")
  1141.                 game:GetService("ContextActionService"):UnbindAction(tostring(i))
  1142.             end
  1143.         end
  1144.        
  1145.         --if math.floor(char.Humanoid.MoveDirection.Z) >= 1 then
  1146.         --  left = true
  1147.         --else
  1148.         --  left = false
  1149.         --end
  1150.         --if  math.floor(char.Humanoid.MoveDirection.Z) <= -1 then
  1151.         --  right = true
  1152.         --else
  1153.         --  right = false
  1154.         --end
  1155.         --if math.floor(char.Humanoid.MoveDirection.X) < -0.1 then
  1156.         --  up = true
  1157.         --else
  1158.         --  up = false
  1159.         --end
  1160.         --if math.floor(char.Humanoid.MoveDirection.X) > 0.1 then
  1161.         --  down = true
  1162.         --else
  1163.         --  down = false
  1164.         --end
  1165.  
  1166.        
  1167.         if char.Data.WallJump.Value >= 1 then
  1168.             if char.Humanoid.FloorMaterial == Enum.Material.Air then
  1169.                 local Ray = Ray.new(char.HumanoidRootPart.Position, char.HumanoidRootPart.CFrame.LookVector*2)
  1170.                 --DrawRay(char.HumanoidRootPart.Position, char.HumanoidRootPart.CFrame.LookVector*3)
  1171.                 local Wall, HitPosition, Normal, Material = workspace:FindPartOnRayWithWhitelist(Ray, {workspace.Render.MapHitbox})
  1172.                 if Wall then -- If wall is in front of you
  1173.                     if (left or right) and not char.HumanoidRootPart:FindFirstChild("WallSlide") and char.Humanoid.FloorMaterial == Enum.Material.Air then
  1174.                         if sliding == false then
  1175.                             ResetVelocity()
  1176.  
  1177.                             char.HumanoidRootPart.AssemblyLinearVelocity *= Vector3.new(0,0,0)
  1178.                             effects.Show("PlaySoundPart", char.Head.Position, game.ReplicatedStorage.Sounds.MantisClaw)
  1179.                             dashcd = false
  1180.                             print("reseting")
  1181.                         end
  1182.                         if char.HumanoidRootPart.Position.Z - Wall.Position.Z > 0 then
  1183.                             slidingDir = "right"
  1184.                         else
  1185.                             slidingDir = "left"
  1186.                         end
  1187.                         sliding = true
  1188.                         if not char.Head:FindFirstChild("WallSlideSound") then
  1189.                             local wss = game.ReplicatedStorage.Sounds.WallSlideSound:Clone()
  1190.                             wss.Parent = char.Head
  1191.                             wss:Play()
  1192.                         end
  1193.                         workspace.Gravity = 30
  1194.                         char.HumanoidRootPart.AssemblyLinearVelocity = Vector3.new(
  1195.                             char.HumanoidRootPart.AssemblyLinearVelocity.X,
  1196.                             math.clamp(char.HumanoidRootPart.AssemblyLinearVelocity.Y, -10, 0),
  1197.                             char.HumanoidRootPart.AssemblyLinearVelocity.Z)
  1198.                     else
  1199.                         sliding = false
  1200.                         if char.Head:FindFirstChild("WallSlideSound") then char.Head:FindFirstChild("WallSlideSound"):Destroy() end
  1201.                         if workspace.Gravity == 30 then workspace.Gravity = 192.5 end
  1202.                     end
  1203.                 else
  1204.                     sliding = false
  1205.                     if char.Head:FindFirstChild("WallSlideSound") then char.Head:FindFirstChild("WallSlideSound"):Destroy() end
  1206.  
  1207.                     if workspace.Gravity == 30 then workspace.Gravity = 192.5 end
  1208.                 end
  1209.             else
  1210.                 sliding = false
  1211.                 if char.Head:FindFirstChild("WallSlideSound") then char.Head:FindFirstChild("WallSlideSound"):Destroy() end
  1212.  
  1213.                 if workspace.Gravity == 30 then workspace.Gravity = 192.5 end
  1214.             end
  1215.         end
  1216.  
  1217.         char.HumanoidRootPart.AssemblyLinearVelocity = Vector3.new(
  1218.             char.HumanoidRootPart.AssemblyLinearVelocity.X,
  1219.             math.clamp(char.HumanoidRootPart.AssemblyLinearVelocity.Y, -50, 200),
  1220.             char.HumanoidRootPart.AssemblyLinearVelocity.Z)
  1221.  
  1222.         if  char.Humanoid.MoveDirection ~= Vector3.new(0,0,0) and char.Humanoid.FloorMaterial ~= Enum.Material.Air then
  1223.             if char.Humanoid.FloorMaterial == Enum.Material.Grass then
  1224.                 PlayWalkingSound(true, "Stone")
  1225.             elseif char.Humanoid.FloorMaterial == Enum.Material.Metal then
  1226.                 PlayWalkingSound(true, "Metal")
  1227.             elseif char.Humanoid.FloorMaterial == Enum.Material.Brick then
  1228.                 PlayWalkingSound(true, "Bones")
  1229.             elseif char.Humanoid.FloorMaterial == Enum.Material.Ice then
  1230.                 PlayWalkingSound(true, "Water")
  1231.             else
  1232.                 PlayWalkingSound(true, "Stone")
  1233.             end
  1234.         else
  1235.             PlayWalkingSound(false)
  1236.         end
  1237.  
  1238.         if (char.Humanoid.MoveDirection == Vector3.new(0,0,-1) or char.Humanoid.MoveDirection == Vector3.new(0,0,1)) and animation.Name ~= "Walk" then
  1239.             animation:Stop()
  1240.             animation = char.Humanoid:LoadAnimation(game.ReplicatedStorage.Animations.Player.Walk)
  1241.             animation:Play()
  1242.         elseif char.Humanoid.MoveDirection == Vector3.new(0,0,0) and animation.Name ~= "Idle" then
  1243.             animation:Stop()
  1244.             animation = char.Humanoid:LoadAnimation(game.ReplicatedStorage.Animations.Player.Idle)
  1245.             animation:Play()
  1246.         end
  1247.     end
  1248. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement