Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function ray2(startpos, endpos, dis, partt)
- local test = Ray.new(startpos, CFrame.new(startpos, endpos).lookVector * dis)
- local hit, pos, sf = game.Workspace:FindPartOnRay(test, partt)
- return hit, pos, sf
- end
- wallup = false
- local treejumping = false
- function wallrun(value)
- if treejumping then return end
- if value then
- if ActionConditions() or Character:FindFirstChild("Shunpo") then return end
- local n = (#Player:FindFirstChild("CombatTags"):GetChildren() > 0)
- if n and Humanoid.Health < Humanoid.MaxHealth/2 then return end
- if inair == true and Humanoid.Health > Humanoid.MaxHealth * 0.3 and not Root:findFirstChild("WallRun") then
- if not Root:findFirstChild("WallRun") then
- ra = nil
- flyang = 0
- flydir = ""
- sfnom = Vector3.new(0, 0, 0)
- right_ray, useless, sf = ray2(Root.Position, Root.Position + (Root.CFrame * CFrame.Angles(0, math.rad(90), 0)).lookVector, 3, Character)
- if right_ray and right_ray.Transparency ~= 1 and right_ray.Name ~= "NoClimb" then
- ra = right_ray
- flyang = 90
- flydir = "right"
- sfnom = sf
- end
- left_ray, useless, sf = ray2(Root.Position, Root.Position + (Root.CFrame * CFrame.Angles(0, math.rad(-90), 0)).lookVector, 3, Character)
- if left_ray and left_ray.Transparency ~= 1 and left_ray.Name ~= "NoClimb" then
- ra = left_ray
- flyang = -90
- flydir = "left"
- sfnom = sf
- end
- forward_ray, useless, sf = ray2(Root.Position, Root.Position + (Root.CFrame * CFrame.Angles(0, math.rad(0), 0)).lookVector, 4, Character)
- if forward_ray and forward_ray.Transparency ~= 1 and forward_ray.Name ~= "NoClimb" then
- ra = forward_ray
- flyang = 0
- flydir = "forward"
- sfnom = sf
- end
- if ra and ra.Transparency ~= 1 and ra.Name ~= "NoClimb" then
- bv = Instance.new("BodyVelocity")
- bv.maxForce = Vector3.new(0, 10000000, 0)
- bv.Parent = Root
- if runanim ~= nil then
- runanim:Stop()
- end
- runanim = Humanoid:LoadAnimation(script.Animations.Movement.FlyUp)
- if flydir == "right" then
- bv.maxForce = Vector3.new(10000000, 10000000, 10000000)
- runanim = Humanoid:LoadAnimation(script.Animations.Movement.FlyLeft)
- elseif flydir == "left" then
- bv.maxForce = Vector3.new(10000000, 10000000, 10000000)
- runanim = Humanoid:LoadAnimation(script.Animations.Movement.FlyRight)
- end
- runanim:Play()
- if flydir == "forward" then
- if Character.Torso.Transparency == 1 then
- bv.velocity = Vector3.new(0, 60, 0)
- else
- bv.velocity = Vector3.new(0, 30, 0)
- end
- else
- if Character.Torso.Transparency == 1 then
- bv.velocity = (CFrame.new(ra.Position, ra.Position + sfnom) * CFrame.Angles(0, math.rad(flyang), 0)).lookVector * 60
- else
- bv.velocity = (CFrame.new(ra.Position, ra.Position + sfnom) * CFrame.Angles(0, math.rad(flyang), 0)).lookVector * 30
- end
- Root.CFrame = CFrame.new(Root.Position, Root.Position + bv.velocity)
- end
- bv.Name = "WallRun"
- bv.Parent = Root
- wallup = true
- canDoubleJump = true
- sub(function()
- while true do
- RunService.Heartbeat:wait()
- ra = ray2(Root.Position, Root.Position + (Root.CFrame * CFrame.Angles(0, math.rad(flyang), 0)).lookVector, 4, Character)
- if ra and ra.Transparency ~= 1 and ra.Name ~= "NoClimb" then
- else
- bv:Destroy()
- --print("stop")
- wallup = false
- if runanim ~= nil then
- runanim:Stop()
- end
- break
- end
- end
- end)
- else
- if canDoubleJump == true and Humanoid.Health >= Humanoid.MaxHealth * 0.3 then
- canDoubleJump = false
- --Character.Torso.Velocity = Character.Torso.Velocity * Vector3.new(1, 0, 1) + Vector3.new(0, 50, 0)
- if runanim ~= nil then
- runanim:Stop()
- end
- --runanim = Humanoid:LoadAnimation(script.Animations.Movement.Flip)
- --runanim:Play()
- else
- end
- end
- end
- elseif Root:findFirstChild("WallRun") then
- bv.maxForce = Vector3.new(10000000, 10000000, 10000000)
- if runanim ~= nil then
- runanim:Stop()
- end
- runanim = Humanoid:LoadAnimation(script.Animations.Movement.Flip)
- runanim:Play()
- if flydir == "forward" then
- Root.WallRun.velocity = Vector3.new(0, 50, 0) + Root.CFrame.lookVector * -30
- Root.WallRun.velocity = Root.CFrame.lookVector * 50 + CFrame.new(ra.Position, ra.Position + sfnom).lookVector * 40
- end
- end
- else
- wallup = false
- --print("stop")
- if Root:FindFirstChild("WallRun") then
- Root:FindFirstChild("WallRun"):Destroy()
- end
- if runanim ~= nil then
- runanim:Stop()
- end
- end
- end
- function lock(part)
- if part and part:IsA("BasePart") then
- part.LocalTransparencyModifier = part.Transparency
- part.Changed:connect(function (property)
- part.LocalTransparencyModifier = part.Transparency
- end)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement