Late reply, sorry i was at school, but where do i put the if ClosestPart and...
block? And as for the OnAir thing, imma just put the whole script so u can see for urself
--||Service(s)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local Debris = game:GetService("Debris")
local UIS = game:GetService("UserInputService")
local CAS = game:GetService("ContextActionService")
--||Variable(s)
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local Animator = Humanoid.Animator
local Root : BasePart = Character:WaitForChild("HumanoidRootPart")
local Animations = Character:WaitForChild("Animations")
local Controls = require(Player.PlayerScripts.PlayerModule):GetControls()
local Mouse = Player:GetMouse()
--------------------------------------
local Effects = ReplicatedStorage:WaitForChild("Effects")
local Events = ReplicatedStorage:WaitForChild("Events")
local Sounds = ReplicatedStorage:WaitForChild("Sounds")
local Utilities = ReplicatedStorage:WaitForChild("Utilities")
local Settings = Character:WaitForChild("Settings")
local Expressions = require(Utilities.Expressions)
local Bezier = require(Utilities.Bezier)
local Controls = require(Player.PlayerScripts.PlayerModule):GetControls()
local Bools = {
Bolting = Settings.Bolting,
Drifting = Settings.Drifting,
Tramping = Settings.Tramping,
Hurting = Settings.Hurting,
Moveset = Settings.Moveset
}
local Anims = {
Bolt = Animator:LoadAnimation(Animations.Ring),
Drift = Animator:LoadAnimation(Animations.Drift),
Tramp = Animator:LoadAnimation(Animations.Tramp)
}
--||Function(s)
--Disable all Ragdoll Physics.
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Ragdoll, false)
Humanoid:SetStateEnabled(Enum.HumanoidStateType.FallingDown, false)
--|Targeting
local function Targeting()
print("a")
if Bools.Moveset.Value == true then
print("c")
local Params = OverlapParams.new()
Params.FilterType = Enum.RaycastFilterType.Exclude
Params.FilterDescendantsInstances = {Character}
local TargetPart = nil
repeat
local Parts = workspace:GetPartBoundsInRadius(Root.Position, 30, Params)
print("a")
--------------------------------------
local MaxDistance = 9999
local ClosestPart = nil
for _, Part : Part in pairs(Parts) do
local Magnitude = (Part.Position - Root.Position).Magnitude
if Part:HasTag("Target") and Magnitude < MaxDistance then
MaxDistance = Magnitude
ClosestPart = Part
end
end
--------------------------------------
if ClosestPart then
ClosestPart.Target.Enabled = true
end
if TargetPart then
TargetPart.Target.Enabled = false
end
if ClosestPart and ClosestPart ~= TargetPart then
ClosestPart.Target.Enabled = true
end
TargetPart = ClosestPart
--------------------------------------
task.wait()
until Humanoid:GetState() ~= Enum.HumanoidStateType.Freefall and Humanoid:GetState() ~= Enum.HumanoidStateType.Jumping
if TargetPart then
TargetPart.Target.Enabled = false
end
end
end
--|Wall Jump
local PreviousWall = nil
local NearWall = nil
local OnAir = false
local function WallJump()
if Bools.Moveset.Value == true then
local Connection = UIS.JumpRequest:Connect(function()
if NearWall and NearWall ~= PreviousWall then
PreviousWall = NearWall
Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
Expressions:Swap("Happy", "Blink", "BoredClosed", "WallJump")
--------------------------------------
if Root:FindFirstChild("WJEffect") then
Root.WJEffect:Destroy()
elseif Root:FindFirstChild("WJSound") then
Root.WJSound:Destroy()
end
--------------------------------------
local Sound = Sounds.Player.WJSound:Clone()
Sound.Parent = Root
Sound.PlaybackSpeed = math.random(9, 10)/10
Sound:Play()
--------------------------------------
local Effect = Effects.Player.WJEffect:Clone()
Effect.Parent = Root
Effect.CFrame = Root.CFrame
local TweenInform = TweenInfo.new(0.25, Enum.EasingStyle.Linear, Enum.EasingDirection.In)
local TweenEffectSize = TweenService:Create(Effect.GUI.ImageLabel, TweenInform, {Size = UDim2.new(1, 0, 1, 0)})
local TweenEffectTransparency = TweenService:Create(Effect.GUI.ImageLabel, TweenInform, {ImageTransparency = 1})
TweenEffectSize:Play()
TweenEffectTransparency:Play()
--------------------------------------
Debris:AddItem(Effect, 0.25)
Debris:AddItem(Sound, 1)
end
end)
--------------------------------------
while Humanoid:GetState() == Enum.HumanoidStateType.Freefall or Humanoid:GetState() == Enum.HumanoidStateType.Jumping do
local Params = OverlapParams.new()
Params.FilterType = Enum.RaycastFilterType.Exclude
Params.FilterDescendantsInstances = {Character}
--------------------------------------
local Parts = workspace:GetPartBoundsInRadius(Root.Position, 1.5, Params)
--------------------------------------
for _, Part : Part in ipairs(Parts) do
if Part:HasTag("Wall Jump") then
NearWall = Part
break
else
NearWall = nil
end
end
task.wait()
end
--------------------------------------
Connection:Disconnect()
NearWall = nil
PreviousWall = nil
else
return
end
end
--|Bolt / Sweep
local HasBolted = false
local function BoltOrSweep()
if Bools.Moveset.Value == true then
if Humanoid:GetState() == Enum.HumanoidStateType.Freefall and not Root.Anchored then
if Bools.Bolting.Value == false and Bools.Drifting.Value == false and Bools.Tramping.Value == false then
local Params = RaycastParams.new()
Params.FilterType = Enum.RaycastFilterType.Exclude
Params.FilterDescendantsInstances = {Character}
--------------------------------------
local CloseToWall = false
--------------------------------------
spawn(function()
local Raycast = workspace:Raycast(Root.Position, Root.CFrame.LookVector * 2, Params)
while Humanoid:GetState() == Enum.HumanoidStateType.Freefall do
if Raycast then
if Raycast.Instance then
CloseToWall = true
break
else
CloseToWall = false
end
end
task.wait()
end
end)
--------------------------------------
if not CloseToWall then
--------------------------------------
Bools.Bolting.Value = true
HasBolted = true
Anims.Bolt:Play(0, 20, 1)
--------------------------------------
if Bools.Hurting.Value == false then
Expressions:Swap("Surprised", "Happy", "HappyOpen", "Bolt")
end
--------------------------------------
Humanoid.AutoRotate = false
--------------------------------------
local Sound = Sounds.Player.BoltSound:Clone()
Sound.Parent = Root
Sound.PlaybackSpeed = math.random(9,10)/10
Sound:Play()
Debris:AddItem(Sound, 1.5)
--------------------------------------
local Attachment = Instance.new("Attachment", Root)
Attachment.Position = Vector3.new(0, 0, 0)
Attachment.Name = "BoltAttachment"
--------------------------------------
local Direction = Root.CFrame.LookVector
local Velocity = Instance.new("LinearVelocity", Root)
Velocity.Name = "BoltVelocity"
Velocity.VectorVelocity = Direction * 120
Velocity.Attachment0 = Attachment
Velocity.MaxForce = math.huge
--------------------------------------
local Params = RaycastParams.new()
Params.FilterType = Enum.RaycastFilterType.Exclude
Params.FilterDescendantsInstances = {Character}
--------------------------------------
spawn(function()
while Bools.Bolting.Value == true do
local Raycast = workspace:Spherecast(Root.Position, 5, Root.CFrame.LookVector * 1, Params)
if Raycast then
if Raycast.Instance then
Attachment:Destroy()
Velocity:Destroy()
--------------------------------------
Bools.Bolting.Value = false
--------------------------------------
Anims.Bolt:Stop()
break
end
end
task.wait()
end
end)
--------------------------------------
Debris:AddItem(Attachment, 0.25)
Debris:AddItem(Velocity, 0.25)
--------------------------------------
local Effect = Effects.Player.BoltEffect:Clone()
Effect.Parent = workspace
Effect.Position = Root.Position
Effect.Orientation = Root.Orientation - Vector3.new(0, 0, 90)
local TweenInform = TweenInfo.new(0.25, Enum.EasingStyle.Linear, Enum.EasingDirection.In)
local TweenEffectSize = TweenService:Create(Effect, TweenInform, {Size = Vector3.new(8, 8, 0.1)})
local TweenEffectTransparency1 = TweenService:Create(Effect.Front.ImageLabel, TweenInform, {ImageTransparency = 1})
local TweenEffectTransparency2 = TweenService:Create(Effect.Back.ImageLabel, TweenInform, {ImageTransparency = 1})
TweenEffectSize:Play()
TweenEffectTransparency1:Play()
TweenEffectTransparency2:Play()
--------------------------------------
Debris:AddItem(Effect, 0.25)
--------------------------------------
spawn(function()
task.wait(.25)
--------------------------------------
Bools.Bolting.Value = false
--------------------------------------
Humanoid.AutoRotate = true
--------------------------------------
if Character:GetAttribute("Expression") == "Bolt" and Bools.Hurting.Value == false then
Expressions:Swap("Happy", "Happy", "HappyClosed", "Happy")
elseif Character:GetAttribute("Expression") ~= "Bolt" or Bools.Hurting.Value == true then
return
end
end)
--------------------------------------
repeat
task.wait()
until Humanoid:GetState() ~= Enum.HumanoidStateType.Freefall
--------------------------------------
HasBolted = false
end
end
end
else
return
end
end
--|Drift
local function Drift()
if Humanoid:GetState() == Enum.HumanoidStateType.Freefall and not Root.Anchored then
if Bools.Bolting.Value == false and Bools.Drifting.Value == false and Bools.Tramping.Value == false then
Anims.Drift.Priority = Enum.AnimationPriority.Action4
Anims.Drift:Play(1, 10, 1)
--------------------------------------
Bools.Drifting.Value = true
--------------------------------------
if Bools.Hurting.Value == false then
Expressions:Swap("Happy", "Down", "Curious", "Drift")
end
--------------------------------------
local Effect1 = Effects.Player.DriftParticles:Clone()
Effect1.Parent = Character.Tick1
local Effect2 = Effects.Player.DriftParticles:Clone()
Effect2.Parent = Character.Tick2
--------------------------------------
local Sound = Sounds.Player.DriftSound:Clone()
Sound.Parent = Root
Sound:Play()
Sound.PlaybackSpeed = math.random(9,10)/10
--------------------------------------
local Velocity = Instance.new("BodyVelocity", Root)
Velocity.Name = "DriftVelocity"
Velocity.P = 5000
Velocity.MaxForce = Vector3.new(0, 50000000, 0)
Velocity.Velocity = Vector3.new(0, -10, 0)
--------------------------------------
repeat
task.wait()
until Humanoid:GetState() == Enum.HumanoidStateType.Landed or Root.Anchored or NearWall
--------------------------------------
Bools.Drifting.Value = false
Effect1:Destroy()
Effect2:Destroy()
Sound:Destroy()
Velocity:Destroy()
Anims.Drift:Stop()
--------------------------------------
if Character:GetAttribute("Expression") == "Drift" and Bools.Hurting.Value == false then
Expressions:Swap("Happy", "Happy", "HappyClosed", "Happy")
elseif Character:GetAttribute("Expression") ~= "Drift" or Bools.Hurting.Value == true then
return
end
elseif Bools.Drifting.Value == true then
Bools.Drifting.Value = false
--------------------------------------
if Humanoid.FloorMaterial == Enum.Material.Air then
Expressions:Swap("Happy", "Down", "BoredClosed", "Falling")
else
return
end
--------------------------------------
Anims.Drift:Stop()
Root.DriftSound:Destroy()
--------------------------------------
Character.Tick1.DriftParticles:Destroy()
Character.Tick2.DriftParticles:Destroy()
Root.DriftVelocity:Destroy()
end
end
end
--|Tramp
local function Tramp()
if Bools.Moveset.Value == true then
if Humanoid:GetState() == Enum.HumanoidStateType.Freefall and Bools.Bolting.Value == false and Bools.Drifting.Value == false and Bools.Tramping.Value == false then
--------------------------------------
Anims.Tramp:Play(0, 25)
--------------------------------------
local Sound0 = Sounds.Player.WooshSound:Clone()
Sound0.Parent = Root
Sound0.PlaybackSpeed = math.random(9, 10)/10
--------------------------------------
Sound0:Play()
--------------------------------------
Debris:AddItem(Sound0, 0.25)
--------------------------------------
Expressions:Swap("Happy", "Blink", "BoredClosed", "Tramp")
--------------------------------------
Bools.Tramping.Value = true
--------------------------------------
local Direction = Root.CFrame.UpVector
local TVelocity = Instance.new("BodyVelocity", Root)
TVelocity.Name = "RecoilVelocity"
TVelocity.Velocity = -Direction * 100
TVelocity.MaxForce = Vector3.new(0, 75000, 0)
--------------------------------------
repeat
task.wait()
until Humanoid.FloorMaterial ~= Enum.Material.Air
--------------------------------------
Anims.Tramp:Play(0, 25)
--------------------------------------
spawn(function()
task.wait(0.25)
Anims.Tramp:Stop()
if Character:GetAttribute("Expression") == "Tramp" and Bools.Tramping.Value == false then
Expressions:Swap("Happy", "Down", "Curious", "Recoil")
elseif Character:GetAttribute("Expression") ~= "Tramp" or Bools.Tramping.Value == true then
return
end
end)
--------------------------------------
local Sound1 = Sounds.Player.WJSound:Clone()
Sound1.Parent = Root
Sound1.PlaybackSpeed = math.random(9, 10)
--------------------------------------
Sound1:Play()
--------------------------------------
Debris:AddItem(Sound1, 4)
--------------------------------------
TVelocity:Destroy()
--------------------------------------
local Direction = Root.CFrame.UpVector
local RVelocity = Instance.new("BodyVelocity", Root)
RVelocity.Name = "RecoilVelocity"
RVelocity.Velocity = Direction * 60
RVelocity.MaxForce = Vector3.new(0, 75000, 0)
--------------------------------------
Debris:AddItem(RVelocity, 0.125)
--------------------------------------
local Params = RaycastParams.new()
Params.FilterType = Enum.RaycastFilterType.Exclude
Params.FilterDescendantsInstances = {Character}
--------------------------------------
local Raycast = workspace:Raycast(Root.Position, -Root.CFrame.UpVector * 10, Params)
if Raycast then
if Raycast.Instance and not Raycast.Instance.Parent:HasTag("Collectible") then
Root.Position = Raycast.Position + Vector3.new(0, 1.25, 0)
local Effect = Effects.Player.TrampEffect:Clone()
Effect.Parent = workspace
Effect.CFrame = CFrame.new(Raycast.Position, Raycast.Position + Raycast.Normal)
--------------------------------------
local TweenInform = TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.In)
local TweenEffectSize = TweenService:Create(Effect, TweenInform, {Size = Vector3.new(8, 8, 0.1)})
local TweenEffectTransparency = TweenService:Create(Effect.GUI.ImageLabel, TweenInform, {ImageTransparency = 1})
local TweenEffectRotation = TweenService:Create(Effect.GUI.ImageLabel, TweenInform, {Rotation = 360})
TweenEffectSize:Play()
TweenEffectTransparency:Play()
TweenEffectRotation:Play()
--------------------------------------
Debris:AddItem(Effect, 0.5)
end
end
--------------------------------------
task.wait()
--------------------------------------
Bools.Tramping.Value = false
end
else
return
end
end
--|Input Handling
local function ActionHandler(ActionName, InputState, InputObject)
if ActionName == "Bolt/Sweep" and InputState == Enum.UserInputState.Begin then
BoltOrSweep()
elseif ActionName == "Drift" and InputState == Enum.UserInputState.Begin then
Drift()
elseif ActionName == "Tramp" and InputState == Enum.UserInputState.Begin then
Tramp()
end
end
--|State Handling
local OnAir2 = false
local function StateHandler(Old, New)
if New == Enum.HumanoidStateType.Freefall and not OnAir2 then
OnAir2 = true
Targeting()
OnAir2 = false
elseif (New == Enum.HumanoidStateType.Freefall or New == Enum.HumanoidStateType.Jumping) and not OnAir then
WallJump()
end
end
--||Connections
--UIS.JumpRequest:Connect(DoubleJump)
CAS:BindAction("Bolt/Sweep", ActionHandler, false, Enum.KeyCode.Q)
CAS:BindAction("Drift", ActionHandler, false, Enum.KeyCode.E)
CAS:BindAction("Tramp", ActionHandler, false, Enum.KeyCode.F)
Humanoid.StateChanged:Connect(StateHandler)
RunService.RenderStepped:Connect(function()
if Bools.Moveset.Value == false then
for _, Bool in pairs(Bools) do
if Bool ~= Bools.Hurting and Bool ~= Bools.Moveset then
Bool.Value = false
end
end
for _, Anim in pairs(Anims) do
Anim:Stop()
end
for _, Obj in pairs(Root:GetChildren()) do
if string.match(Obj.Name, "Bolt") or string.match(Obj.Name, "Drift") or string.match(Obj.Name, "Tramp") then
Obj:Destroy()
end
end
return
end
end)