I'm making a fighting game (another jojo game) and I'm having problems with making a hitbox using raycast. It's saying that the variable "CastResults" == nil
Extra Information: The variable "Stand" is a model, containing R6 Rigparts, it's primarypart is the HumanoidRootPart
My failed output:
ServerScriptService.StandServerHandler:233: attempt to index nil with 'Instance'
My raycast code:
local RaycastParameters = RaycastParams.new()
RaycastParameters.FilterType = Enum.RaycastFilterType.Blacklist
RaycastParameters.FilterDescendantsInstances = {Stand, Character}
RaycastParameters.IgnoreWater = true
local CastResults = Workspace:Raycast(Stand.PrimaryPart.CFrame.Position, Stand.PrimaryPart.CFrame.LookVector * 500, RaycastParameters)
local Hit = CastResults.Instance -- Line 233
local HitPosition = CastResults.Position
local Surface = CastResults.Normal
local Material = CastResults.Material.Name

2 comments
You don't need [Unsolved] in your title. :)
The mathematics used to draw the ray is likely the root of your issue. If your RaycastResult Object is nil, the ray didn't make contact with an Instance; it's best to account for this in the future.