I do not know what I’m doing wrong but when I’m trying to make a raycast follow a player nothing happens. I’ve lookd up several solutuions however all of them use the deprecated versions.
This is the most crucial part of the code I’m using:
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
raycastParams.IgnoreWater = true
RunService.RenderStepped:Connect(function()
local NPCHEAD = NPC.Head.Position
local PlayHead = Player.Head.Position
local raycastResult = workspace:Raycast(NPCHEAD, PlayHead, raycastParams)
if raycastResult then
if raycastResult:IsAncestorOf(Char) then
game.Workspace.Baseplate.BrickColor = BrickColor.new("Really red")
else
game.Workspace.Baseplate.BrickColor = BrickColor.new("Lime green")
end
end
end
I left out some variables to keep the snippet short, all variables are defined and no error code is displayed.