Hello everyone,
I am new to using raycasts and I am trying to create a script that allows me to tell if there is an object between two set attachments.
Unfortunately right now the result of the ray cast is always returning nil in every circumstance or arrangement despite the code seeming to look okay
Here is my code:
local blade = workspace:WaitForChild("blade",5)
local top = blade.Top
local base = blade.Base
local function castRay()
local direction = Vector3.new(0,-100,0) --top.Position - base.Position
local params = RaycastParams.new()
params.FilterDescendantsInstances = {blade}
params.IgnoreWater = true;
params.FilterType = Enum.RaycastFilterType.Blacklist
local res = workspace:Raycast(base.Position,direction,params)
print(res)
end
game:GetService("RunService").Heartbeat:Connect(function()
castRay()
end)
Any help is appreciated, thanks in advance