For a test world, I have tried to use raycasting just to find a block ahead, nothing else. It’s a test for a different thing which relies on raycastResult.Instance working.
this has been the result. The raycasting operation, as you can see from the screenshot, should’ve worked properly (unless I’m missing something quite obvious) but when I try and print raycastResult.Instance it prints nothing.
I have tried setting it to a variable then printing; I get the same output.
Any help is appreciated
Yeah this is quite confusing it has to be said. The ray does seem to be hitting something as the material is plastic and the usual ray cast result things are displayed.
Could it be a spelling mistake in the actual script?
-- var
local origin = script.Parent.Position
local finalval = script.Parent.CFrame * CFrame.new(0,0,50)
local final = finalval.Position
local children = workspace.detectors:GetChildren()
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Whitelist
raycastParams.IgnoreWater = true
raycastParams.FilterDescendantsInstances = children
local raycastResult = workspace:Raycast(origin, final, raycastParams)
print("3")
print(raycastResult)
print(raycastResult.Instance)
print("4")
Here’s the entire unchanged code script.parent is a BasePart from which the ray is being fired finalval is just for working final is the target of the ray detectors contains the base part for which is the target
Rest is self explanatory.
It seems to ignore the second print(raycastResult) - far from what I expected. There are not any errors related to this bit of code - only some remnants from some other script.
Hi, I managed to get it working - can you provide a short snippet of your code so that I can see what went wrong? In my case it was not understanding what an instance was - raycastResult.Instance when it has hit a part will return Instance and you can get the properties of that through raycastResult.Instance.Name for example.