You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Raycast for normal
-
What is the issue? Raycast returns nil for seemingly no reason?
-
What solutions have you tried so far? I’ve looked through most of the topics about that problem but it didn’t help
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local Hit = game.Workspace:GetPartsInPart(Hitbox)
local HitList = {}
--Find Humanoids in the hitbox
for i, v in pairs(Hit) do
if v.Parent:FindFirstChild("Humanoid") then
if v.Parent:FindFirstChild("State"):GetAttribute("Iframe") == true then break end
if Blockable == true or Blockable == nil then
if v.Parent:FindFirstChild("State"):GetAttribute("Block") == true then --check if enemy is blocking
local RayCastParams = RaycastParams.new()
RayCastParams.FilterType = Enum.RaycastFilterType.Include
RayCastParams.IncludeInstances = {v.Parent.HumanoidRootPart}
local startpos = plr.Character.HumanoidRootPart.Position
local endpos = v.Parent.HumanoidRootPart.Position
local distance = (startpos - endpos).Magnitude
local rayResult = workspace:Raycast(startpos,(startpos - endpos).Unit * distance, RayCastParams)
print(rayResult)
if rayResult then
print(rayResult)
if rayResult.Normal == Vector3.new(0,0,1) then
print("Front")
end
end
end
end
if not table.find(HitList, v.Parent) and v.Parent.Name ~= plr.Name then
table.insert(HitList, v.Parent)
end
end
end
here’s most of the script
it’s in modulescript and called by server