Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Creator: YeahLamma
- Description: Hollow Knight game handler on client side.
- Creator notes: This is an year old code, did not used to comment stuff,
- since I remember most stuff where everything is and how is used.
- Nowdays I only use commenting only in group projects or when its
- example of data transfer between client and server and vise versa.
- ]]
- local char = script.Parent
- local plr = game.Players:GetPlayerFromCharacter(char)
- local data = char.Data
- local UIS = game:GetService("UserInputService")
- local ZPModule = require(game.ReplicatedStorage.ModuleScripts.Zone)
- local remots = game.ReplicatedStorage.Remotes
- local showbox = require(game.ReplicatedStorage.ModuleScripts.HitboxVisible)
- local effects = require(game.ReplicatedStorage.ModuleScripts.Effects)
- local AIModule = require(game.ReplicatedStorage.ModuleScripts.AIs)
- repeat task.wait() until plr:FindFirstChild("loadedData") and plr.PlayerGui:FindFirstChild("Interface")
- local function waitForInputType(inputType)
- while true do
- local input, processed = UIS.InputBegan:Wait()
- if processed then continue end
- if input.KeyCode == inputType then break end
- end
- end
- local function roomLoad(roomName, SavePoint)
- plr.PlayerGui.Interface.Fade.BackgroundTransparency = 0
- char.HumanoidRootPart.Anchored = true
- local splitRoomName = string.split(roomName, ":")
- char.Data.Room.Value = splitRoomName[1] or roomName
- local room = game.ReplicatedStorage.Rooms:FindFirstChild(char.Data.Room.Value):Clone()
- if workspace:FindFirstChild("Render") then
- for i, v in pairs(workspace.Render.Background:GetChildren()) do
- for _, v2 in pairs(room.Background:GetChildren()) do
- if v2.SoundId == v.SoundId then
- v2.TimePosition = v.TimePosition
- end
- end
- end
- workspace.Render:Destroy()
- end
- room.Name = "Render"
- room.Parent = workspace
- if not SavePoint then
- if not splitRoomName[2] then
- if char.Data.LastRoom.Value == "" or not room.TeleportPoints:FindFirstChild(char.Data.LastRoom.Value) then
- char:MoveTo(room.TeleportPoints.Default.Position)
- else
- char:MoveTo(room.TeleportPoints:FindFirstChild(char.Data.LastRoom.Value).Position)
- end
- else
- char.Data.Checkpoint.Value = room.TeleportPoints:FindFirstChild(splitRoomName[2])
- char:MoveTo(room.TeleportPoints:FindFirstChild(splitRoomName[2]).Position)
- end
- else
- if not room:FindFirstChild("SavePoint") then
- char:MoveTo(room.TeleportPoints.Default.Position)
- char.Data.Checkpoint.Value = room.TeleportPoints.Default
- else
- char:MoveTo(room.SavePoint.Position)
- char.Data.Checkpoint.Value = room.SavePoint
- end
- for i, v in pairs(plr.Data:GetChildren()) do
- if char.Data:FindFirstChild(v.Name) and not v:IsA("Folder") then
- char.Data:FindFirstChild(v.Name).Value = v.Value
- end
- end
- char.Data.Lives.Value = char.Data.MaxLives.Value
- char.Data.Mana.Value = 100
- char.Data.RoomData:ClearAllChildren()
- for i, v in pairs(plr.Data.RoomData:GetChildren()) do
- v:Clone().Parent = char.Data.RoomData
- end
- end
- for i, v in pairs(room:GetDescendants()) do
- if v.Name == "Save" then
- if char.Data.RoomData:FindFirstChild(v.Value) then
- v.Parent.Parent:Destroy()
- end
- elseif v.Name == "PlayLoopSound" then
- local loopSound = game.ReplicatedStorage.Sounds:FindFirstChild(v.Value):Clone()
- loopSound.Parent = v.Parent.Parent.Hitbox
- loopSound:Play()
- end
- end
- if room:FindFirstChild("SceneJumps") then
- for i, v in pairs(room.SceneJumps:GetChildren()) do
- if not v:FindFirstChild("Input") then
- v.Touched:Connect(function(hit)
- if hit:IsDescendantOf(char) then
- char.Data.LastRoom.Value = char.Data.Room.Value
- roomLoad(v.Name)
- end
- end)
- else
- local SP = ZPModule.new(v)
- local inside = false
- local TEXTO = nil
- SP.playerEntered:Connect(function(plyr: Player)
- if plyr == plr then
- inside = true
- if TEXTO == nil then
- TEXTO = script.RandomText:Clone()
- TEXTO.Text = "Press W to enter"
- TEXTO.Parent = plr.PlayerGui.Interface
- end
- while true do
- if inside == false then break end
- local input, processed = UIS.InputBegan:Wait()
- if processed then continue end
- if input.KeyCode == Enum.KeyCode.W then break end
- end
- if inside == true then
- if game.ReplicatedStorage.Rooms:FindFirstChild(string.split(v.Name, ":")[1]) then
- char.Data.LastRoom.Value = char.Data.Room.Value
- roomLoad(v.Name)
- end
- if TEXTO ~= nil then
- TEXTO:Destroy()
- TEXTO = nil
- end
- end
- end
- end)
- SP.playerExited:Connect(function(plyr: Player)
- if plyr == plr then
- inside = false
- if TEXTO then
- TEXTO:Destroy()
- TEXTO = nil
- end
- end
- end)
- end
- end
- end
- if room:FindFirstChild("Spikes") then
- for i, v in pairs(room.Spikes:GetChildren()) do
- if v.Data:FindFirstChild("Moving") then
- local destinations = {}
- for _, val in pairs(string.split(v.Data.Moving.Value, ":")) do
- if v:FindFirstChild(val) then
- table.insert(destinations, v:FindFirstChild(val))
- end
- end
- spawn(function()
- local dest = false
- while v and v:FindFirstChild("Hitbox") do
- if dest == false then
- 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()
- task.wait(2.3)
- dest = true
- else
- 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()
- task.wait(2.3)
- dest = false
- end
- end
- end)
- end
- v.Hitbox.Touched:Connect(function(hit)
- if hit.Name == "Hitbox"and hit:IsDescendantOf(char) and not char.Data:FindFirstChild("IFRAME") then
- if char.Data.Lives.Value > 1 then
- local iframespike = Instance.new("StringValue")
- iframespike.Name = "IFRAME"
- iframespike.Parent = char.Data
- game.Debris:AddItem(iframespike, 1.3)
- char.Data.Lives.Value -= 1
- char.HumanoidRootPart.Anchored = true
- task.wait(0.3)
- game.TweenService:Create(plr.PlayerGui.Interface.Fade, TweenInfo.new(.15), {BackgroundTransparency = 0}):Play()
- char:MoveTo(char.Data.Checkpoint.Value.Position or room.TeleportPoints.Default.Position)
- task.wait(1)
- char.HumanoidRootPart.Anchored = false
- game.TweenService:Create(plr.PlayerGui.Interface.Fade, TweenInfo.new(.15), {BackgroundTransparency = 1}):Play()
- else
- char.Data.Lives.Value = 0
- end
- end
- end)
- end
- end
- if room:FindFirstChild("Zones") then
- for i, v in pairs(room.Zones:GetChildren()) do
- local zoneZP = ZPModule.new(v)
- local conn = nil
- local TEXTO = nil
- zoneZP.playerEntered:Connect(function(plyr: Player)
- if plyr == plr then
- local inside = true
- conn = zoneZP.playerExited:Connect(function(plyr: Player)
- if plyr == plr then
- inside = false
- if TEXTO then
- TEXTO:Destroy()
- TEXTO = nil
- end
- conn:Disconnect()
- end
- end)
- if v.Data.TypeZone.Value == "RemovePart" then
- if v.Data:FindFirstChild("Save") then
- local change = Instance.new("StringValue")
- change.Name = v.Data.Save.Value
- change.Parent = char.Data.RoomData
- end
- v.Data.Remover.Value:Destroy()
- v:Destroy()
- elseif v.Data.TypeZone.Value == "SetSpawnpoint" then
- if char.Data.Checkpoint.Value ~= v.Data.Checkpoint.Value then
- char.Data.Checkpoint.Value = v.Data.Checkpoint.Value
- end
- elseif v.Data.TypeZone.Value == "UpgradeAbility" then
- if TEXTO == nil then
- TEXTO = script.RandomText:Clone()
- TEXTO.Text = "Press W to Pick Up"
- TEXTO.Parent = plr.PlayerGui.Interface
- end
- waitForInputType(Enum.KeyCode.W)
- if inside then
- local skillUp = string.split(v.Data.Skill.Value, ":")
- char.Data:FindFirstChild(skillUp[1]).Value = skillUp[2]
- if v.Data:FindFirstChild("Save") then
- local change = Instance.new("StringValue")
- change.Name = v.Data.Save.Value
- change.Parent = char.Data.RoomData
- v:Destroy()
- end
- if TEXTO ~= nil then
- TEXTO:Destroy()
- TEXTO = nil
- end
- end
- elseif v.Data.TypeZone.Value == "TextAppear" then
- waitForInputType(Enum.KeyCode.W)
- if inside then
- local TEXTO = script.RandomText:Clone()
- TEXTO.Text = v.Data.Title.Value
- TEXTO.Parent = plr.PlayerGui.Interface
- game.Debris:AddItem(TEXTO, 2)
- if v.Data:FindFirstChild("Save") then
- local change = Instance.new("StringValue")
- change.Name = v.Data.Save.Value
- change.Parent = char.Data.RoomData
- v:Destroy()
- end
- end
- elseif v.Data.TypeZone.Value == "PlaySound" then
- local soundo = v.Data.Object.Value:Clone()
- v:Destroy()
- soundo.Parent = workspace
- soundo:Play()
- game.Debris:AddItem(soundo, soundo.TimeLength +1)
- elseif v.Data.TypeZone.Value == "ChangeBackground" then
- local savedTime = room.Background:FindFirstChildOfClass("Sound").TimePosition
- for i, v in pairs(room.Background:GetChildren()) do
- if v:IsA("Sound") then
- v:Stop()
- end
- end
- local soundo = v.Data.Object.Value:Clone()
- soundo.Parent = room.Background
- soundo.TimePosition = savedTime
- local fade = false
- if v.Data:FindFirstChild("Fade") then
- fade = true
- local savedVolume = soundo.Volume
- soundo.Volume = 0
- game.TweenService:Create(soundo, TweenInfo.new(0.75), {Volume = savedVolume}):Play()
- end
- soundo:Play()
- elseif v.Data.TypeZone.Value == "PlaySoundUntilLeave" then
- local soundo = v.Data.Object.Value:Clone()
- soundo.Parent = workspace
- local fade = false
- if v.Data:FindFirstChild("Fade") then
- fade = true
- local savedVolume = soundo.Volume
- soundo.Volume = 0
- game.TweenService:Create(soundo, TweenInfo.new(0.75), {Volume = savedVolume}):Play()
- end
- soundo:Play()
- --game.Debris:AddItem(soundo, soundo.TimeLength +1)
- spawn(function()
- repeat task.wait() until inside == false
- if fade then
- game.TweenService:Create(soundo, TweenInfo.new(0.75), {Volume = 0}):Play()
- task.wait(0.8)
- soundo:Destroy()
- else
- soundo:Destroy()
- end
- end)
- end
- end
- end)
- end
- end
- if room:FindFirstChild("SavePoint") then
- local SP = ZPModule.new(room.SavePoint)
- local TEXTO = nil
- local conn = nil
- SP.playerEntered:Connect(function(plyr: Player)
- if plyr == plr then
- local inside = true
- conn = SP.playerExited:Connect(function(plyr: Player)
- if plyr == plr then
- inside = false
- if TEXTO then
- TEXTO:Destroy()
- TEXTO = nil
- end
- conn:Disconnect()
- end
- end)
- if TEXTO == nil then
- TEXTO = script.RandomText:Clone()
- TEXTO.Text = "Press W to Save"
- TEXTO.Parent = plr.PlayerGui.Interface
- end
- waitForInputType(Enum.KeyCode.W)
- if inside then
- char.Data.SavePoint.Value = char.Data.Room.Value
- char.Data.Mana.Value = 100
- local roomChangeTable = {}
- for i, v in pairs(char.Data.RoomData:GetChildren()) do
- table.insert(roomChangeTable, v.Name)
- end
- local datatoSave = {}
- for i, v in pairs(char.Data:GetChildren()) do
- if plr.Data:FindFirstChild(v.Name) and not v:IsA("Folder") then
- datatoSave[v.Name] = v.Value
- end
- end
- remots.RemoteEvent:FireServer("Save", datatoSave, roomChangeTable)
- char.Data.Lives.Value = char.Data.MaxLives.Value
- if TEXTO ~= nil then
- TEXTO.Text = "SAVED"
- wait(1)
- if TEXTO ~= nil then
- TEXTO:Destroy()
- TEXTO = nil
- end
- end
- end
- end
- end)
- end
- if room:FindFirstChild("Background") then
- for i, v in pairs(room.Background:GetChildren()) do
- if v:IsA("Sound") then
- v:Play()
- end
- end
- end
- if room:FindFirstChild("Enemies") then
- for i, v in pairs(room.Enemies:GetChildren()) do
- if v:FindFirstChild("Data") and v.Data:FindFirstChild("AIType") then
- AIModule.Create(v.Data.AIType.Value, v, plr)
- end
- end
- end
- char.HumanoidRootPart.Anchored = false
- game.TweenService:Create(plr.PlayerGui.Interface.Fade, TweenInfo.new(.15), {BackgroundTransparency = 1}):Play()
- end
- for i, v in pairs(char:GetDescendants()) do
- if v:IsA("BasePart") and v.Name ~= "HumanoidRootPart" then
- v.Massless = true
- end
- end
- if plr.Data.SavePoint.Value == "" then
- roomLoad("KP1", true)
- else
- roomLoad(plr.Data.SavePoint.Value, true)
- end
- ------------------------------------------------------------------- EVERYTHING LOADED
- repeat task.wait() until data.Room.Value ~= ""
- script.WalkingSounds.Parent = char.HumanoidRootPart
- local function PlayWalkingSound(state, name)
- if state == true then
- for i, v in pairs(char.HumanoidRootPart.WalkingSounds:GetChildren()) do
- if v.Name == name then
- if v.Playing == false then
- v.Playing = true
- end
- else
- v.Playing = false
- end
- end
- else
- for i, v in pairs(char.HumanoidRootPart.WalkingSounds:GetChildren()) do
- v.Playing = false
- end
- end
- end
- local function ResetVelocity()
- char.HumanoidRootPart.AssemblyLinearVelocity *= Vector3.new(0,0,0)
- if char.HumanoidRootPart:FindFirstChild("Dash") then char.HumanoidRootPart:FindFirstChild("Dash"):Destroy() end
- if char.HumanoidRootPart:FindFirstChild("Pogo") then char.HumanoidRootPart:FindFirstChild("Pogo"):Destroy() end
- if char.HumanoidRootPart:FindFirstChild("PlayerPush") then char.HumanoidRootPart:FindFirstChild("PlayerPush"):Destroy() end
- if char.HumanoidRootPart:FindFirstChild("JumpForce") then char.HumanoidRootPart:FindFirstChild("JumpForce"):Destroy() end
- if char.HumanoidRootPart:FindFirstChild("2XJump") then char.HumanoidRootPart:FindFirstChild("2XJump"):Destroy() end
- end
- function createForce(name, att, force)
- local vectorForce = Instance.new("VectorForce")
- vectorForce.Attachment0 = att
- vectorForce.Name = name
- vectorForce.RelativeTo = Enum.ActuatorRelativeTo.Attachment0
- vectorForce.Force = att.CF * workspace.Gravity * char.HumanoidRootPart:GetMass() * force
- vectorForce.ApplyAtCenterOfMass = true
- vectorForce.Parent = char.HumanoidRootPart
- return vectorForce
- end
- local LastMDirection = Vector3.new()
- local right = false
- local left = false
- local up = false
- local down = false
- local dashcd = false
- local slashcd = false
- local canNotDoAnything = false
- local jumps = 2
- local sliding = false
- local slidingDir = "left"
- UIS.InputBegan:Connect(function(input, isTyping)
- if isTyping then return end
- local PCKeys = string.split(plr.Data.PCControls.Value, "_RAMS_")
- if input.KeyCode == Enum.KeyCode.Thumbstick1 then
- print("Left", input.Delta.X)
- end
- if input.KeyCode == Enum.KeyCode.D then
- right = true
- LastMDirection = Vector3.new(0,0,-1)
- elseif input.KeyCode == Enum.KeyCode.A then
- left = true
- LastMDirection = Vector3.new(0,0,1)
- elseif input.KeyCode == Enum.KeyCode.S then
- down = true
- elseif input.KeyCode == Enum.KeyCode.W then
- up = true
- elseif input.KeyCode == Enum.KeyCode[PCKeys[7]] then
- plr.PlayerGui.Interface.Inventory.Visible = not plr.PlayerGui.Interface.Inventory.Visible
- elseif input.KeyCode == Enum.KeyCode[PCKeys[4]] then
- if canNotDoAnything or char.Data.Mana.Value < 33 then return end
- local inputDown = true
- local sound = nil
- local conn = nil
- conn = UIS.InputEnded:Connect(function(input2, isTyping)
- if input2.KeyCode == Enum.KeyCode[PCKeys[4]] then
- inputDown = false
- if sound then
- sound:Destroy()
- end
- canNotDoAnything = false
- conn:Disconnect()
- end
- end)
- task.delay(.25, function()
- if inputDown == false then
- if char.Data.Mana.Value >= 33 then
- if up then
- if char.Data.WSpell.Value >= 1 then
- char.Humanoid.WalkSpeed = 16
- char.Data.Mana.Value -= 33
- print("SHRIEK")
- end
- elseif down and char.Humanoid:GetState() == Enum.HumanoidStateType.Freefall then
- if char.Data.SSpell.Value >= 1 then
- char.Humanoid.WalkSpeed = 16
- char.Data.Mana.Value -= 33
- print("Smash")
- end
- elseif LastMDirection == Vector3.new(0,0,-1) or LastMDirection == Vector3.new(0,0,1) then
- if char.Data.ADSpell.Value >= 1 then
- char.Humanoid.WalkSpeed = 16
- char.Data.Mana.Value -= 33
- print("FIREBALL")
- end
- end
- end
- else
- if char.Data.Mana.Value >= 33 and char.Data.Lives.Value < char.Data.MaxLives.Value then
- local soundo = game.ReplicatedStorage.Sounds.Charge:Clone()
- sound = soundo
- soundo.Parent = char.Head
- soundo:Play()
- game.Debris:AddItem(soundo, soundo.TimeLength +1)
- char.Humanoid.WalkSpeed = 0
- canNotDoAnything = true
- end
- end
- end)
- task.delay(1.141, function()
- if inputDown == true then
- if char.Data.Mana.Value >= 33 then
- local soundo = game.ReplicatedStorage.Sounds:FindFirstChild("Heal"):Clone()
- soundo.Parent = char.Head
- soundo:Play()
- game.Debris:AddItem(soundo, soundo.TimeLength +1)
- char.Data.Mana.Value -= 33
- char.Data.Lives.Value = math.clamp(char.Data.Lives.Value+1, 1, char.Data.MaxLives.Value)
- while inputDown and char.Data.Mana.Value >= 33 and char.Data.Lives.Value < char.Data.MaxLives.Value do
- task.wait(.891)
- if inputDown and char.Data.Mana.Value >= 33 and char.Data.Lives.Value < char.Data.MaxLives.Value then
- local soundo = game.ReplicatedStorage.Sounds:FindFirstChild("Heal"):Clone()
- soundo.Parent = char.Head
- soundo:Play()
- game.Debris:AddItem(soundo, soundo.TimeLength +1)
- char.Data.Mana.Value -= 33
- char.Data.Lives.Value = math.clamp(char.Data.Lives.Value+1, 1, char.Data.MaxLives.Value)
- end
- end
- if sound then
- sound:Destroy()
- end
- char.Humanoid.WalkSpeed = 16
- end
- else
- char.Humanoid.WalkSpeed = 16
- end
- canNotDoAnything = false
- end)
- elseif input.KeyCode == Enum.KeyCode[PCKeys[3]] then
- if canNotDoAnything then return end
- if char.Data.Dash.Value >= 1 then
- if not dashcd then
- dashcd = true
- ResetVelocity()
- local animo = char.Humanoid:LoadAnimation(game.ReplicatedStorage.Animations.Player.Dash)
- animo:Play()
- local bv = Instance.new("BodyVelocity")
- bv.MaxForce = Vector3.new(99999,10000,99999)
- local pos = -55
- if LastMDirection == Vector3.new(0,0,1) then
- pos = 55
- end
- bv.Velocity = Vector3.new(0,0,pos)
- bv.Name = "Dash"
- bv.Parent = char.HumanoidRootPart
- local soundo = game.ReplicatedStorage.Sounds:FindFirstChild("Dash"):Clone()
- soundo.Parent = char.Head
- soundo:Play()
- game.Debris:AddItem(soundo, soundo.TimeLength +1)
- game.Debris:AddItem(bv, .2)
- task.delay(.2, function()
- animo:Stop()
- animo:Destroy()
- end)
- if char.Humanoid:GetState() ~= Enum.HumanoidStateType.Freefall then
- task.delay(.72, function()
- dashcd = false
- end)
- end
- end
- end
- elseif input.KeyCode == Enum.KeyCode[PCKeys[5]] then
- if canNotDoAnything then return end
- local inputDown = true
- local soundo = game.ReplicatedStorage.Sounds.SuperDashCharge:Clone()
- soundo.Parent = char.Head
- soundo:Play()
- game.Debris:AddItem(soundo, soundo.TimeLength +1)
- char.Humanoid.WalkSpeed = 0
- canNotDoAnything = true
- local conn = nil
- conn = UIS.InputEnded:Connect(function(input2, isTyping)
- if input2.KeyCode == Enum.KeyCode[PCKeys[5]] then
- inputDown = false
- if soundo then
- soundo:Destroy()
- end
- canNotDoAnything = false
- char.Humanoid.WalkSpeed = 16
- char.HumanoidRootPart.Anchored = false
- conn:Disconnect()
- end
- end)
- if sliding == true and char.Humanoid:GetState() == Enum.HumanoidStateType.Freefall then
- char.Humanoid.WalkSpeed = 0
- char.HumanoidRootPart.Anchored = true
- char.HumanoidRootPart.AssemblyLinearVelocity *= Vector3.new(0,0,0)
- task.delay(0.8, function()
- if inputDown == true then
- conn:Disconnect()
- local soundor = game.ReplicatedStorage.Sounds.SuperDashReady:Clone()
- soundor.Parent = char.Head
- soundor:Play()
- game.Debris:AddItem(soundor, soundor.TimeLength+1)
- while true do
- local input, processed = UIS.InputEnded:Wait()
- if processed then continue end
- if input.KeyCode == Enum.KeyCode[PCKeys[5]] then break end
- end
- local soundor = game.ReplicatedStorage.Sounds.SuperDashBurst:Clone()
- soundor.Parent = char.Head
- soundor:Play()
- game.Debris:AddItem(soundor, soundor.TimeLength+1)
- local dashLoop = game.ReplicatedStorage.Sounds.SuperDashLoop:Clone()
- dashLoop.Parent = char.Head
- dashLoop:Play()
- char.HumanoidRootPart.Anchored = false
- local bv = Instance.new("BodyVelocity")
- bv.MaxForce = Vector3.new(99999,10000,99999)
- local pos = -66
- if LastMDirection == Vector3.new(0,0,1) then
- pos = 66
- end
- bv.Velocity = Vector3.new(0,0,pos)
- bv.Name = "Dash"
- bv.Parent = char.HumanoidRootPart
- char.Humanoid.WalkSpeed = 16
- local stop = false
- spawn(function()
- while true do
- local Ray = Ray.new(char.HumanoidRootPart.Position, char.HumanoidRootPart.CFrame.LookVector*3)
- --DrawRay(char.HumanoidRootPart.Position, char.HumanoidRootPart.CFrame.LookVector*3)
- local Wall, HitPosition, Normal, Material = workspace:FindPartOnRayWithWhitelist(Ray, {workspace.Render.MapHitbox})
- if Wall then -- If wall is in front of you
- stop = true
- local soundor = game.ReplicatedStorage.Sounds.SuperDashHitWall:Clone()
- soundor.Parent = char.Head
- soundor:Play()
- game.Debris:AddItem(soundor, soundor.TimeLength+1)
- break
- end
- task.wait()
- end
- end)
- spawn(function()
- while true do
- local input, processed = UIS.InputBegan:Wait()
- if processed then continue end
- if input.KeyCode == Enum.KeyCode.A or input.KeyCode == Enum.KeyCode.D then
- stop = true
- local soundor = game.ReplicatedStorage.Sounds.SuperDashAirBrake:Clone()
- soundor.Parent = char.Head
- soundor:Play()
- game.Debris:AddItem(soundor, soundor.TimeLength+1)
- break
- end
- end
- end)
- repeat task.wait() until stop == true
- dashLoop:Destroy()
- bv:Destroy()
- if soundo then
- soundo:Destroy()
- end
- canNotDoAnything = false
- char.Humanoid.WalkSpeed = 16
- char.HumanoidRootPart.Anchored = false
- else
- char.Humanoid.WalkSpeed = 16
- end
- end)
- elseif sliding == false and char.Humanoid:GetState() ~= Enum.HumanoidStateType.Freefall then
- char.Humanoid.WalkSpeed = 0
- task.delay(0.8, function()
- if inputDown == true then
- conn:Disconnect()
- local soundor = game.ReplicatedStorage.Sounds.SuperDashReady:Clone()
- soundor.Parent = char.Head
- soundor:Play()
- game.Debris:AddItem(soundor, soundor.TimeLength+1)
- while true do
- local input, processed = UIS.InputEnded:Wait()
- if processed then continue end
- if input.KeyCode == Enum.KeyCode[PCKeys[5]] then break end
- end
- local soundor = game.ReplicatedStorage.Sounds.SuperDashBurst:Clone()
- soundor.Parent = char.Head
- soundor:Play()
- game.Debris:AddItem(soundor, soundor.TimeLength+1)
- local dashLoop = game.ReplicatedStorage.Sounds.SuperDashLoop:Clone()
- dashLoop.Parent = char.Head
- dashLoop:Play()
- local bv = Instance.new("BodyVelocity")
- bv.MaxForce = Vector3.new(99999,10000,99999)
- local pos = -66
- if LastMDirection == Vector3.new(0,0,1) then
- pos = 66
- end
- bv.Velocity = Vector3.new(0,0,pos)
- bv.Name = "Dash"
- bv.Parent = char.HumanoidRootPart
- char.Humanoid.WalkSpeed = 16
- local stop = false
- spawn(function()
- while true do
- local Ray = Ray.new(char.HumanoidRootPart.Position, char.HumanoidRootPart.CFrame.LookVector*3)
- --DrawRay(char.HumanoidRootPart.Position, char.HumanoidRootPart.CFrame.LookVector*3)
- local Wall, HitPosition, Normal, Material = workspace:FindPartOnRayWithWhitelist(Ray, {workspace.Render.MapHitbox})
- if Wall then -- If wall is in front of you
- stop = true
- local soundor = game.ReplicatedStorage.Sounds.SuperDashHitWall:Clone()
- soundor.Parent = char.Head
- soundor:Play()
- game.Debris:AddItem(soundor, soundor.TimeLength+1)
- break
- end
- task.wait()
- end
- end)
- spawn(function()
- while true do
- local input, processed = UIS.InputBegan:Wait()
- if processed then continue end
- if input.KeyCode == Enum.KeyCode.A or input.KeyCode == Enum.KeyCode.D then
- stop = true
- local soundor = game.ReplicatedStorage.Sounds.SuperDashAirBrake:Clone()
- soundor.Parent = char.Head
- soundor:Play()
- game.Debris:AddItem(soundor, soundor.TimeLength+1)
- break
- end
- end
- end)
- repeat task.wait() until stop == true
- dashLoop:Destroy()
- bv:Destroy()
- if soundo then
- soundo:Destroy()
- end
- canNotDoAnything = false
- char.Humanoid.WalkSpeed = 16
- char.HumanoidRootPart.Anchored = false
- else
- char.Humanoid.WalkSpeed = 16
- end
- end)
- end
- elseif input.KeyCode == Enum.KeyCode[PCKeys[1]] then
- if canNotDoAnything then return end
- if sliding then
- ResetVelocity()
- effects.Show("PlaySoundPart", char.Head.Position, game.ReplicatedStorage.Sounds.WallJump)
- local bv = Instance.new("BodyVelocity")
- bv.MaxForce = Vector3.new(0,99999,99999)
- bv.Velocity = (char.HumanoidRootPart.CFrame.UpVector * 30) + (char.HumanoidRootPart.CFrame.LookVector * -25) -- You can change the multiplicator value
- bv.Name = "JumpForce"
- bv.Parent = char.HumanoidRootPart
- game.Debris:AddItem(bv, .3)
- task.delay(.1, function()
- if slidingDir == "left" and left == true then
- ResetVelocity()
- bv:Destroy()
- char.HumanoidRootPart.AssemblyLinearVelocity = Vector3.new(0,30,5)
- elseif slidingDir == "right" and right == true then
- ResetVelocity()
- bv:Destroy()
- char.HumanoidRootPart.AssemblyLinearVelocity = Vector3.new(0,30,-5)
- end
- end)
- jumps = 1
- else
- if char.Humanoid:GetState() ~= Enum.HumanoidStateType.Freefall then
- effects.Show("PlaySoundPart", char.Head.Position, game.ReplicatedStorage.Sounds.Jump)
- ResetVelocity()
- local bv = Instance.new("BodyVelocity")
- bv.MaxForce = Vector3.new(0,99999,0)
- bv.Velocity = char.HumanoidRootPart.CFrame.UpVector * 30 -- You can change the multiplicator value
- bv.Name = "JumpForce"
- bv.Parent = char.HumanoidRootPart
- jumps = 1
- game.Debris:AddItem(bv, .3)
- else
- if char.Data.DoubleJump.Value >= 1 then
- if jumps >= 1 then
- jumps = 0
- effects.Show("PlaySoundPart", char.Head.Position, game.ReplicatedStorage.Sounds.DoubleJump)
- ResetVelocity()
- local bv = Instance.new("BodyVelocity")
- bv.MaxForce = Vector3.new(0,99999,0)
- bv.Velocity = char.HumanoidRootPart.CFrame.UpVector * 30 -- You can change the multiplicator value
- bv.Name = "2XJump"
- bv.Parent = char.HumanoidRootPart
- game.Debris:AddItem(bv, .3)
- end
- end
- end
- end
- elseif input.KeyCode == Enum.KeyCode[PCKeys[2]] then
- if canNotDoAnything then return end
- if not slashcd then
- slashcd = true
- local op = OverlapParams.new()
- op.FilterType = Enum.RaycastFilterType.Exclude
- op.FilterDescendantsInstances = char:GetDescendants()
- local hits = {}
- local pos
- local size = Vector3.new(5,5.5,6.8)
- local dir = ""
- if up then
- dir = "up"
- size = Vector3.new(8,5.5,10)
- pos = CFrame.new(char.HumanoidRootPart.Position + Vector3.new(0,5,0), char.HumanoidRootPart.Position + Vector3.new(0,6,0)) * CFrame.Angles(0,0,0)
- elseif down and char.Humanoid:GetState() == Enum.HumanoidStateType.Freefall then
- dir = "down"
- size = Vector3.new(8,5.5,11)
- pos = CFrame.new(char.HumanoidRootPart.Position + Vector3.new(0,-5,0), char.HumanoidRootPart.Position + Vector3.new(0,-6,0)) * CFrame.Angles(0,0,0)
- elseif LastMDirection == Vector3.new(0,0,-1) then
- dir = "right"
- pos = CFrame.new(char.HumanoidRootPart.Position + Vector3.new(0,0,-5), char.HumanoidRootPart.Position) * CFrame.Angles(0,0,0)
- char.Humanoid:LoadAnimation(game.ReplicatedStorage.Animations.Player.SlashRight):Play()
- else
- dir = "left"
- pos = CFrame.new(char.HumanoidRootPart.Position + Vector3.new(0,0,5), char.HumanoidRootPart.Position) * CFrame.Angles(0,0,0)
- char.Humanoid:LoadAnimation(game.ReplicatedStorage.Animations.Player.SlashRight):Play()
- end
- task.delay(0.2,function()
- effects.Show("Slash", dir, char)
- end)
- local hitbox = workspace:GetPartBoundsInBox(pos, size, op)
- --showbox.Show(size, pos, .75)
- local canPogo = false
- for _, v in pairs(hitbox) do
- if v.Name == "Hitbox" and not table.find(hits,v.Parent) then
- table.insert(hits, v.Parent)
- --local hit = RS.hit:Clone()
- --hit.TextLabel.Text = "Hit"
- --hit.Adornee = v
- --hit.TextLabel.Position = UDim2.new(math.random(0,50)/100,0,math.random(0,82)/100,0)
- --hit.Parent = v
- --game.Debris:AddItem(hit, 1.25)
- if not v.Parent.Data:FindFirstChild("NOKNOCK") then
- canPogo = true
- end
- if not v.Parent.Data:FindFirstChild("IFRAME") then
- if v.Parent.Data:FindFirstChild("ObjectHits") then
- if v.Parent.Data.ObjectHits.Value > 1 then
- v.Parent.Data.ObjectHits.Value -= 1
- if v.Parent.Data:FindFirstChild("DamageSound") then
- local splitString = string.split(v.Parent.Data:FindFirstChild("DamageSound").Value, ":")
- if #splitString > 1 then
- effects.Show("PlaySoundPart", v.Position, game.ReplicatedStorage.Sounds:FindFirstChild(splitString[math.random(#splitString)]))
- else
- effects.Show("PlaySoundPart", v.Position, game.ReplicatedStorage.Sounds:FindFirstChild(splitString[1]))
- end
- end
- if v.Parent.Name == "GeoRock" then
- effects.Show("ExplodeMoney", v.CFrame * CFrame.Angles(0,0,0), math.random(1,2), plr)
- end
- else
- if v.Parent.Data:FindFirstChild("Save") then
- local change = Instance.new("StringValue")
- change.Name = v.Parent.Data.Save.Value
- change.Parent = char.Data.RoomData
- end
- if v.Parent.Data:FindFirstChild("DeathSound") then
- local splitString = string.split(v.Parent.Data:FindFirstChild("DeathSound").Value, ":")
- if #splitString > 1 then
- effects.Show("PlaySoundPart", v.Position, game.ReplicatedStorage.Sounds:FindFirstChild(splitString[math.random(#splitString)]))
- else
- effects.Show("PlaySoundPart", v.Position, game.ReplicatedStorage.Sounds:FindFirstChild(splitString[1]))
- end
- end
- if v.Parent.Data:FindFirstChild("RandomDropMoney") then
- effects.Show("ExplodeMoney", v.CFrame * CFrame.Angles(0,0,0), math.random(1,25), plr)
- end
- v.Parent:Destroy()
- end
- else
- char.Data.Mana.Value = math.clamp(char.Data.Mana.Value + 11, 0, 100)
- if v.Parent.Data.Lives.Value > char.Data.Damage.Value then
- v.Parent.Data.Lives.Value -= char.Data.Damage.Value
- if not v.Parent.Data:FindFirstChild("UNKNOCK") then
- local bv = Instance.new("BodyVelocity",v.Parent.HumanoidRootPart)
- bv.MaxForce = Vector3.new(99999,99999,99999)
- bv.Name = "EnemyPush"
- bv.P = 10
- bv.Velocity = CFrame.new(v.Parent.HumanoidRootPart.Position, char.HumanoidRootPart.Position).LookVector * -15
- game.Debris:AddItem(bv,.2)
- end
- effects.Show("PlaySoundPart", v.Position, game.ReplicatedStorage.Sounds.EnemyDamage)
- else
- effects.Show("PlaySoundPart", v.Position, game.ReplicatedStorage.Sounds.EnemyDeath)
- if v.Parent.Data:FindFirstChild("DropMoney") then
- effects.Show("ExplodeMoney", v.CFrame * CFrame.Angles(0,0,0), v.Parent.Data.DropMoney.Value, plr)
- end
- v.Parent:Destroy()
- end
- end
- end
- end
- end
- if #hits > 0 and dir ~= "up" and canPogo == true then
- ResetVelocity()
- jumps = 1
- dashcd = false
- local bv = Instance.new("BodyVelocity")
- bv.MaxForce = Vector3.new(99999,0,99999)
- bv.Name = "Pogo"
- bv.P = 10
- bv.Parent = char.HumanoidRootPart
- if dir == "down" then
- bv.MaxForce = Vector3.new(0,99999,0)
- bv.Velocity = char.HumanoidRootPart.CFrame.UpVector * 17
- game.Debris:AddItem(bv,.2)
- else
- bv.Velocity = char.HumanoidRootPart.CFrame.LookVector * -15
- game.Debris:AddItem(bv,.2)
- end
- end
- task.delay(.42, function()
- slashcd = false
- end)
- end
- end
- end)
- UIS.InputEnded:Connect(function(input, isTyping)
- if isTyping then return end
- local PCKeys = string.split(plr.Data.PCControls.Value, "_RAMS_")
- if input.KeyCode == Enum.KeyCode.D then
- right = false
- elseif input.KeyCode == Enum.KeyCode.A then
- left = false
- elseif input.KeyCode == Enum.KeyCode.S then
- down = false
- elseif input.KeyCode == Enum.KeyCode.W then
- up = false
- elseif input.KeyCode == Enum.KeyCode[PCKeys[1]] then
- if char.HumanoidRootPart:FindFirstChild("JumpForce") then char.HumanoidRootPart:FindFirstChild("JumpForce"):Destroy() end
- if char.HumanoidRootPart:FindFirstChild("2XJump") then char.HumanoidRootPart:FindFirstChild("2XJump"):Destroy() end
- end
- end)
- char.Humanoid.StateChanged:Connect(function(_, state)
- if state == Enum.HumanoidStateType.Landed then
- if char.Head:FindFirstChild("Fall") then
- char.Head:FindFirstChild("Fall"):Destroy()
- end
- char.Humanoid:LoadAnimation(game.ReplicatedStorage.Animations.Player.Land):Play()
- local Ray = Ray.new(char.HumanoidRootPart.Position, char.HumanoidRootPart.CFrame.UpVector * -3)
- --DrawRay(char.HumanoidRootPart.Position, char.HumanoidRootPart.CFrame.LookVector*3)
- local Wall, HitPosition, Normal, Material = workspace:FindPartOnRayWithWhitelist(Ray, {workspace.Render.MapHitbox})
- if Wall then -- If wall is in front of you
- if Wall:FindFirstChild("LandSound") then
- effects.Show("PlaySoundPart", char.Head.Position, game.ReplicatedStorage.Sounds:FindFirstChild(Wall.LandSound.Value))
- else
- effects.Show("PlaySoundPart", char.Head.Position, game.ReplicatedStorage.Sounds.LandSoft)
- end
- else
- effects.Show("PlaySoundPart", char.Head.Position, game.ReplicatedStorage.Sounds.LandSoft)
- end
- jumps = 2 -- change to 1 for upgradeable
- dashcd = false
- elseif state == Enum.HumanoidStateType.Freefall then
- if not char.Head:FindFirstChild("Fall") then
- local wss = game.ReplicatedStorage.Sounds.Fall:Clone()
- wss.Parent = char.Head
- wss:Play()
- end
- end
- end)
- local function updateLifeBar()
- for i, v in pairs(plr.PlayerGui.Interface.Lives:GetChildren()) do
- if v:IsA("Frame") then
- v:Destroy()
- end
- end
- for i = 1, char.Data.Lives.Value do
- local LIFER = script.Life:Clone()
- LIFER.Parent = plr.PlayerGui.Interface.Lives
- end
- if char.Data.Lives.Value ~= char.Data.MaxLives.Value then
- for i = 1, char.Data.MaxLives.Value - char.Data.Lives.Value do
- local LIFER = script.Life:Clone()
- LIFER.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
- LIFER.Parent = plr.PlayerGui.Interface.Lives
- end
- end
- end
- updateLifeBar()
- char.Data.MaxLives.Changed:Connect(function()
- updateLifeBar()
- end)
- local NOWLIVES = char.Data.Lives.Value
- char.Data.Lives.Changed:Connect(function()
- updateLifeBar()
- if char.Data.Lives.Value < NOWLIVES then
- if NOWLIVES - char.Data.Lives.Value == 1 then
- effects.Show("PlaySoundPart", char.Head.Position, game.ReplicatedStorage.Sounds.DamageSelf)
- else
- effects.Show("PlaySoundPart", char.Head.Position, game.ReplicatedStorage.Sounds.DamageSelf):FindFirstChildOfClass("Sound").Volume = 1.2
- end
- end
- NOWLIVES = char.Data.Lives.Value
- if char.Data.Lives.Value <= 0 then
- char.PrimaryPart.Anchored = true
- char.Humanoid:LoadAnimation(game.ReplicatedStorage.Animations.Player.Death):Play()
- task.wait(0.05)
- local pxplode = script.DeathPlode:Clone()
- pxplode.Position = char.PrimaryPart.Position
- pxplode.Parent = workspace
- game.TweenService:Create(pxplode, TweenInfo.new(.7), {Size = Vector3.new(50,50,50)}):Play()
- game.Debris:AddItem(pxplode, 1)
- wait(1)
- if plr.Data.SavePoint.Value ~= "" then
- roomLoad(plr.Data.SavePoint.Value, true)
- else
- roomLoad("KP1", true)
- end
- end
- end)
- local function DrawRay(origin: Vector3, direction: Vector3)
- local part = Instance.new("Part")
- part.Name = "Ray"
- part.Anchored = true
- local result = workspace:Raycast(origin, direction)
- local len = (origin - (origin + direction)).Magnitude
- if result then
- len = (origin - result.Position).Magnitude
- end
- part.Size = Vector3.new(1, 1 , len)
- part.Material = Enum.Material.SmoothPlastic
- part.Color = Color3.new(255,255,255)
- part.Transparency = .5
- part.CanCollide = false
- part.CanTouch = false
- part.CFrame = CFrame.new(origin, direction) * CFrame.new(0, 0, -len*0.5)
- part.Parent = workspace
- return part
- end
- local actionTableDisable = {
- "jumpAction";
- "moveForwardAction";
- "moveBackwardAction";
- }
- local animation = char.Humanoid:LoadAnimation(game.ReplicatedStorage.Animations.Player.Idle)
- while task.wait() do
- char.Data.Damage.Value = 5 + (4*char.Data.DamageUpgrade.Value)
- plr.PlayerGui.Interface.Money.Text = char.Data.Money.Value
- plr.PlayerGui.Interface.Mana.Inside.Size = UDim2.new(1,0,char.Data.Mana.Value/100,0)
- if char then
- for i, v in pairs(game.ContextActionService:GetAllBoundActionInfo()) do
- if table.find(actionTableDisable, tostring(i)) then
- print(i.." been unbinded")
- game:GetService("ContextActionService"):UnbindAction(tostring(i))
- end
- end
- --if math.floor(char.Humanoid.MoveDirection.Z) >= 1 then
- -- left = true
- --else
- -- left = false
- --end
- --if math.floor(char.Humanoid.MoveDirection.Z) <= -1 then
- -- right = true
- --else
- -- right = false
- --end
- --if math.floor(char.Humanoid.MoveDirection.X) < -0.1 then
- -- up = true
- --else
- -- up = false
- --end
- --if math.floor(char.Humanoid.MoveDirection.X) > 0.1 then
- -- down = true
- --else
- -- down = false
- --end
- if char.Data.WallJump.Value >= 1 then
- if char.Humanoid.FloorMaterial == Enum.Material.Air then
- local Ray = Ray.new(char.HumanoidRootPart.Position, char.HumanoidRootPart.CFrame.LookVector*2)
- --DrawRay(char.HumanoidRootPart.Position, char.HumanoidRootPart.CFrame.LookVector*3)
- local Wall, HitPosition, Normal, Material = workspace:FindPartOnRayWithWhitelist(Ray, {workspace.Render.MapHitbox})
- if Wall then -- If wall is in front of you
- if (left or right) and not char.HumanoidRootPart:FindFirstChild("WallSlide") and char.Humanoid.FloorMaterial == Enum.Material.Air then
- if sliding == false then
- ResetVelocity()
- char.HumanoidRootPart.AssemblyLinearVelocity *= Vector3.new(0,0,0)
- effects.Show("PlaySoundPart", char.Head.Position, game.ReplicatedStorage.Sounds.MantisClaw)
- dashcd = false
- print("reseting")
- end
- if char.HumanoidRootPart.Position.Z - Wall.Position.Z > 0 then
- slidingDir = "right"
- else
- slidingDir = "left"
- end
- sliding = true
- if not char.Head:FindFirstChild("WallSlideSound") then
- local wss = game.ReplicatedStorage.Sounds.WallSlideSound:Clone()
- wss.Parent = char.Head
- wss:Play()
- end
- workspace.Gravity = 30
- char.HumanoidRootPart.AssemblyLinearVelocity = Vector3.new(
- char.HumanoidRootPart.AssemblyLinearVelocity.X,
- math.clamp(char.HumanoidRootPart.AssemblyLinearVelocity.Y, -10, 0),
- char.HumanoidRootPart.AssemblyLinearVelocity.Z)
- else
- sliding = false
- if char.Head:FindFirstChild("WallSlideSound") then char.Head:FindFirstChild("WallSlideSound"):Destroy() end
- if workspace.Gravity == 30 then workspace.Gravity = 192.5 end
- end
- else
- sliding = false
- if char.Head:FindFirstChild("WallSlideSound") then char.Head:FindFirstChild("WallSlideSound"):Destroy() end
- if workspace.Gravity == 30 then workspace.Gravity = 192.5 end
- end
- else
- sliding = false
- if char.Head:FindFirstChild("WallSlideSound") then char.Head:FindFirstChild("WallSlideSound"):Destroy() end
- if workspace.Gravity == 30 then workspace.Gravity = 192.5 end
- end
- end
- char.HumanoidRootPart.AssemblyLinearVelocity = Vector3.new(
- char.HumanoidRootPart.AssemblyLinearVelocity.X,
- math.clamp(char.HumanoidRootPart.AssemblyLinearVelocity.Y, -50, 200),
- char.HumanoidRootPart.AssemblyLinearVelocity.Z)
- if char.Humanoid.MoveDirection ~= Vector3.new(0,0,0) and char.Humanoid.FloorMaterial ~= Enum.Material.Air then
- if char.Humanoid.FloorMaterial == Enum.Material.Grass then
- PlayWalkingSound(true, "Stone")
- elseif char.Humanoid.FloorMaterial == Enum.Material.Metal then
- PlayWalkingSound(true, "Metal")
- elseif char.Humanoid.FloorMaterial == Enum.Material.Brick then
- PlayWalkingSound(true, "Bones")
- elseif char.Humanoid.FloorMaterial == Enum.Material.Ice then
- PlayWalkingSound(true, "Water")
- else
- PlayWalkingSound(true, "Stone")
- end
- else
- PlayWalkingSound(false)
- end
- if (char.Humanoid.MoveDirection == Vector3.new(0,0,-1) or char.Humanoid.MoveDirection == Vector3.new(0,0,1)) and animation.Name ~= "Walk" then
- animation:Stop()
- animation = char.Humanoid:LoadAnimation(game.ReplicatedStorage.Animations.Player.Walk)
- animation:Play()
- elseif char.Humanoid.MoveDirection == Vector3.new(0,0,0) and animation.Name ~= "Idle" then
- animation:Stop()
- animation = char.Humanoid:LoadAnimation(game.ReplicatedStorage.Animations.Player.Idle)
- animation:Play()
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement