how can i make it so when player is near at top of a brick/part he can grab at top, tried to search on how to do it for so long but only way i can do is to make a another invisible part called grab or something but it will make the game laggy?
local UIS = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local enabled = true
leg = 1
repeat wait() until Player.Character ~= nil
repeat wait() until Player.Character.Humanoid ~= nil
GonnaBeAWallJump = false
local Ignore = Player.Character
on = false
UIS.InputBegan:connect(function(input, gameProcessedEvent)
if game.Players.LocalPlayer.Character:findFirstChild("Running") then return end
if game.Players.LocalPlayer.Character.Humanoid.Health < 25 then return end
if game.Players.LocalPlayer.Character.Humanoid.Jump == true and enabled == true then
if input.KeyCode == Enum.KeyCode.Space and not gameProcessedEvent then
enabled = false
local ray = Ray.new(Player.Character.HumanoidRootPart.CFrame.p, Player.Character.HumanoidRootPart.CFrame.lookVector * 2,5,Player.Character)
hit, pos, thes = game.Workspace:FindPartOnRay(ray, Ignore)
if hit and hit.Parent ~= Player.Character and hit.ClassName ~= "Tool" and hit.Anchored and hit.CanCollide and hit.Transparency ~= 1 and not hit:findFirstChild("NoClimb") and hit.Name ~= "Water" then
--print(hit.Name)
--print(pos)
--print(thes)
local walljumpanim = Player.Character.Humanoid:LoadAnimation(script:FindFirstChild("walljumpanim"))
walljumpanim:Play()
dir = Player.Character.HumanoidRootPart.CFrame*CFrame.Angles(math.rad(-240),0,0)
Player.Character.Torso.Velocity = Vector3.new(Player.Character.Torso.Velocity.X, 50, Player.Character.Torso.Velocity.Z)
wait(.1)
elseif hit.Name == "Grab" and on == false then
--print(hit.Name)
--print(pos)
--print(thes)
on = true
local walljumpanim = Player.Character.Humanoid:LoadAnimation(script:FindFirstChild("grabattop"))
walljumpanim:Play()
--dir = Player.Character.HumanoidRootPart.CFrame*CFrame.Angles(math.rad(-120),0,0)
Player.Character.Torso.Anchored = true
wait(.1)
end
enabled = true
end
end
if input.KeyCode == Enum.KeyCode.Space and not gameProcessedEvent and on == true then
on = false
Player.Character.Anchored = false
wait(.01)
Player.Character.Torso.Velocity = Vector3.new(Player.Character.Torso.Velocity.X, 85, Player.Character.Torso.Velocity.Z)
end
end)

3 comments
idk that looks very long for a parkour script
ok seeing as nobody has yet to help u ill try to figure out an answer
https://scriptinghelpers.org/questions/15273/how-can-i-detect-a-surface-a-part-hit