-
What do you want to achieve?
I want to use a raycast to find if player is block by a part in a direction,If not kill the player -
What is the issue?
So a part had a raycast script and when the player is close eg.100 stud it’ll trigger but when it is above that,There is no result of the raycast,Bear in mind that there is actually a part blocking the player,But i’ve add it to the ignore list -
What solutions have you tried so far?
I’ve try delete the part,Which show me error so the ignore list is getting executed but.ANd when i fix the error it’s still don’t detect the part until i move it close.I heard that there is a limit to raycast distance but that’s 5000 stud not 100.
The code uses workspace:RayCast() function which is entirely taken from roblox dev hub and modfied
wait(20)
local rayOrigin = Vector3.new(-215.352, 160.586, -3.802)
print("ARE YOU READY FOR LASER?")
for _, v in pairs(game.Players:GetChildren()) do
local rayDestination = v.Character.Head.Position
local rayDir = rayDestination - rayOrigin
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {script.Parent}
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
local raycastResult = workspace:Raycast(rayOrigin, rayDir, raycastParams)
if raycastResult ~= nil then
local hitPart = raycastResult.Instance
if hitPart.Parent:FindFirstChildOfClass("Humanoid") then
local hum = hitPart.Parent:FindFirstChildOfClass("Humanoid")
hum.Health = 0
print("Killed " .. v.Name)
end
end
end
Thankyou
Sincerely tin_nim