I am making a building system and the model preview should not be considered on the raycast. However, that is not happening for some reason. Here’s the code that matters:
local function visualizePreview()
if CLIENT_CAST and CLIENT_PLOT_PREVIEW then
if table.find(ClientPreviewFolder:GetChildren(), CLIENT_PLOT_PREVIEW) then
CLIENT_PLOT_PREVIEW:PivotTo(CFrame.new(CLIENT_CAST.Position) * newOriention)
else
for i, instance in ClientPreviewFolder:GetChildren() do
instance:Destroy()
end
CLIENT_PLOT_PREVIEW.Parent = ClientPreviewFolder
end
end
end
local function updateMouseCast()
local mouseLocation = UIS:GetMouseLocation()
local unitRay = camera:ViewportPointToRay(mouseLocation.X, mouseLocation.Y)
local params = RaycastParams.new()
params.FilterType = Enum.RaycastFilterType.Exclude
params.FilterDescendantsInstances = {player.Character, CLIENT_PLOT_PREVIEW}
CLIENT_CAST = workspace:Raycast(unitRay.Origin, unitRay.Direction * MAX_DIST)
print("updated cast: ",CLIENT_CAST)
end
local function onMouseMove()
updateMouseCast()
visualizePreview()
end
edit: btw i am running these functions, not just declaring them