Hello, so i’ve made a WallJump function. Simply put, when the Player jumps/falls, a Spherecast is casted. If the Spherecast exists, then it prints “Casted Sphere.”. Then, if the Spherecast hits a specific WallJump part, then the HumanoidRootPart of the Player gets anchored, and it prints “Hit JumpPanel.”. Or at least, that’s what it’s supposed to do. I do not know or understand why, but the Spherecast here is really inconsistent. If the Player jumps or falls, then the Spherecast will randomly cast. And even then, sometimes it doesn’t do it. AND, if it is touching the WallJump part, it just refuses to print “Hit Jump Panel.” and anchor the HumanoidRootPart, as it’s supposed to. I’ve been trying so hard to fix this, and i even tried raycasting instead, but it had the same exact same issues. Please help, this is extremely frustrating.
local function WallJump()
local Params = RaycastParams.new()
Params.FilterType = Enum.RaycastFilterType.Exclude
Params.FilterDescendantsInstances = {Character}
--------------------------------------
local WJAnim = Animator:LoadAnimation(Animations.HoldWall)
--------------------------------------
local Spherecast = workspace:Spherecast(Root.Position, 5, Root.CFrame.LookVector * 1, Params)
--------------------------------------
if Spherecast then
print("Casted Sphere.")
if Spherecast.Instance and Spherecast.Instance.Name == "Hitbox" and Spherecast.Instance.Parent.Name == "JumpPanel" then
print("Hit JumpPanel.")
Root.Anchored = true
Root.CFrame = CFrame.new(Spherecast.Position, Spherecast.Position + Spherecast.Normal)
end
end
end
local function StateHandler(Old, New)
if New == Enum.HumanoidStateType.Jumping or New == Enum.HumanoidStateType.Freefall then
--[[spawn(function()
if Bools.WallSpotted.Value == false then
task.wait(0.2)
Bools.CanDJ.Value = true
end
end)]]
WallJump()
elseif New == Enum.HumanoidStateType.Landed then
--Bools.CanDJ.Value = false
--Bools.HasDJ.Value = false
end
end