Raycast should shoot towards player to check if monster has line of sight, then kill them, but doesn’t see player (or any instance for that matter. When I tried checking for an instance it threw an error)
script.Parent.Touched:Connect(function(hit)
if game.Players:GetPlayerFromCharacter(hit.Parent) then
local Character = hit.Parent
local Params = RaycastParams.new()
Params.FilterType = Enum.RaycastFilterType.Exclude
Params.IgnoreWater = true
Params.FilterDescendantsInstances = script.Parent:GetDescendants()
local Raycast = workspace:Raycast(script.Parent.Position, (Character.HumanoidRootPart.Position - script.Parent.Position) * 200, Params)
if Raycast then
print("ya!")
if game.Players:GetPlayerFromCharacter(Raycast.Instance.Parent) then
print("ja!")
Raycast.Instance.Parent.Humanoid.Health = 0
end
end
end
end)
Edit: Video of the problem (although probably unnecessary)
5 years of programming to be defeated by this…
Any help is appreciated!