Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --VARIABLES
- --Services
- local RS = game:GetService("RunService")
- local UIS = game:GetService("UserInputService")
- local CAS = game:GetService("ContextActionService")
- local char = script.Parent
- local HumRtPt = script.Parent:WaitForChild("HumanoidRootPart")
- local Hum = script.Parent:WaitForChild("Humanoid")
- --Local variables
- local debouce = false
- local keydebouce = false
- local walljumping = false
- --Predefined local variables
- local weld
- --Audios
- local _Off = script:WaitForChild("_Off")
- local _Hit = script:WaitForChild("_Hit")
- --Predefined connection variables
- local jumpConnection
- local runConnection
- --Functions
- function WaitFunc(s)
- local counter = false
- delay(s,function()
- counter = true
- end)
- repeat wait() until counter
- return true
- end
- --Animation
- local animationInstance = Instance.new("Animation", HumRtPt)
- animationInstance.AnimationId = "rbxassetid://3038214797"
- local animation = Hum:LoadAnimation(animationInstance)
- function WallJumpEvent(part)
- local objV = part:FindFirstChild("_Wall") -- Check if this part is a wall-jump part
- if objV then
- if objV:IsA("ObjectValue") then
- local ray = Ray.new(HumRtPt.Position, HumRtPt.CFrame.LookVector.Unit *2) -- Check if angle is close
- local raypart, pos, normal = workspace:FindPartOnRay(ray,char)
- if raypart == part and not debouce then
- walljumping = true -- Take effects
- debouce = true
- char.Humanoid.WalkSpeed = 0
- HumRtPt.CFrame = CFrame.new(HumRtPt.CFrame.p, HumRtPt.CFrame.p+normal)
- if part:IsDescendantOf(workspace.Lobby) then -- Check if the wall-jump part is the one in the lobby
- part.BrickColor = BrickColor.Red()
- end
- weld = Instance.new("WeldConstraint",HumRtPt) -- Make character stick by the wall
- weld.Part0 = HumRtPt
- weld.Part1 = part
- _Hit:Play()
- animation:Play()
- local timer = 0.7 -- Wait until Space key is press (with debouce) OR after 0.7 seconds
- local starttime = tick()
- local remainingtime = 0.7
- repeat wait() remainingtime = 0.7 - (tick() - starttime) print(remainingtime) until not UIS:IsKeyDown(Enum.KeyCode.Space) or remainingtime <= 0
- repeat wait() remainingtime = 0.7 - (tick() - starttime) until UIS:IsKeyDown(Enum.KeyCode.Space) or remainingtime <= 0
- print("ended")
- walljumping = false
- pcall(function()
- jumpConnection:Disconnect()
- end)
- if part:IsDescendantOf(workspace.Lobby) then
- part.BrickColor = BrickColor.Gray()
- end
- if UIS:IsKeyDown(Enum.KeyCode.Space) and remainingtime > 0 then -- Check if player pressed space during wall jumping
- game.Debris:AddItem(weld,0) -- take effects
- char.Humanoid.WalkSpeed = 20
- HumRtPt.Velocity = HumRtPt.CFrame.LookVector*55 +Vector3.new(0, char.Humanoid.JumpPower, 0)
- animation:Stop()
- _Off:Play()
- delay(0.2,function()
- part.Velocity = Vector3.new(0,0,0)
- debouce = false
- end)
- else
- game.Debris:AddItem(weld,0)
- char.Humanoid.WalkSpeed = 20
- HumRtPt.Velocity = HumRtPt.CFrame.LookVector*10
- delay(0.2,function()
- debouce = false
- end)
- end
- end
- end
- end
- end
- HumRtPt.Touched:Connect(function(part)
- WallJumpEvent(part)
- end)
Advertisement
Advertisement