my goal was to make dash script, and i wanted to make raycast detect if player hitted something on the way then cancel the dash and bounce back
here is the code
`local UIS = game:GetService("UserInputService")
local char = game.Players.LocalPlayer.Character
local HumRootPart = char:FindFirstChild("HumanoidRootPart")
local rootAttach = HumRootPart:WaitForChild("RootAttachment")
local DirLookVec = HumRootPart.CFrame.LookVector
local function RayCast()
local RayOrigin = HumRootPart.Position
local rayResult = workspace:Raycast(RayOrigin, DirLookVec * 1.5)
if rayResult and not rayResult.Instance:IsDescendantOf(char) then
local rayNormal = rayResult.Normal
local XZnormal = Vector3.new(rayNormal.X, 0, rayNormal.Z)
print(rayResult.Instance)
end
end
function module.DivingAndCrouch()
UIS.InputBegan:Connect(function(input, Typing)
if Typing then return end
if input.KeyCode == Enum.KeyCode.C then
print("yea")
local DiveForce = Instance.new("LinearVelocity")
DiveForce.Parent = HumRootPart
DiveForce.Attachment0 = rootAttach
RayCast()
end
end)
end`
note: just follow what title said, i want to make everything said in my goal by myself.