Raycast doesn't work

I have this script:

function Punch(ActionName,InputState,InputObject)
if InputState == Enum.UserInputState.End then return end
print("Punched")
-- RayCasting, oof
local RayOrigin = HumanoidRootPart.Position
local RayDirection = Vector3.new(0,Range.Value,0)
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {Character,InvisibleParts}
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
local Raycast = workspace:Raycast(RayOrigin,RayDirection,raycastParams)
print("Starting Raycast")
if Raycast then
print("Part was hit.")
local HitPart = Raycast.Instance
local TargetCharacter = HitPart.Parent
if not TargetCharacter:FindFirstChildOfClass("Humanoid") then print("No Humanoid was found.") return end
local TargetHumanoid = TargetCharacter.Humanoid
local TargetPlayer = Players:GetPlayerFromCharacter(TargetCharacter)
if TargetHumanoid.Name == "Monster" then
PunchEvent:FireServer(TargetHumanoid,Damage.Value)
else
print(string.format("%s punched %s, that's an illegal move.",Player.Name,TargetPlayer.Name))
end
else
print("No part was hit.")
end
end

However, it won’t print “Part was hit.” when close to a character.
The Range is 5 as a NumberValue and Damage 25 as a NumberValue. Help?

I think it’s because the RayDirection is in the Y vector.

You are firing the ray to the top with Vector3.new(0,Range.Value,0) (Line 6).

However, I suppose you want to punch in the direction your character looks to.
To do that replace the direction with HumanoidRootPart.CFrame.LookVector * Range.Value

Thank you, but would this distance be 5 studs?

Depends on what Range.Value is equal to. You used it in your code so i thought you might have a value for it.

The range value is 5, supposedly to be 5 studs.