You can write your topic however you want, but you need to answer these questions:
**When I clone the blast to workspace I want the region 3 to act as a hit detector to deal dammage and ignore anything without a humanoid in it
**it keeps returning nil
hb stands for hitbox inside the blast
here is the code chunk
local region = Region3.new(hb.Position - (hb.Size/2),hb.Position + (hb.Size / 2))
local hit = workspace:FindPartsInRegion3WithIgnoreList(region,{char},math.huge)
if hit then
print("hit")
print(hit.Name)
local der = hit.Parent:findFirstChild("Humanoid")
if der then
hit.Parent:findFirstChild("Humanoid"):TakeDamage(17)
else
end
end
Line 2: The function can only return 20 parts
Line 2: What is char?
Lines 3-end: hit is going to be an array of BaseParts, so you will need to change the code
This function can only return 20 parts, so this method may not work if you have a lot of parts/players in an area.
I think it is what they wanted. This seems to be intended to ignore a specific player and damage everyone else.
@MainDirectory the points about it being an array and the default limit of 20 are the biggest things to work on first. I imagine this is reflected in errors in the output window about FindFirstChild not being an index of nil.
You should rename hit to hits on the second line, and replace if hit then with for _, hit in ipairs( hits ) do
As a slightly off topic piece of advice, I wouldn’t use regions for this, and instead I would simply do a magnitude check on all other players (and/or NPC’s) to determine if they are within a sphere radius (rather than a cube) of the point of interest, and do damage based on that.
It will be more performant if you use GetPlayers and have a CollectionService tag for your NPCs or keep them all in a specific folder, especially if what you’ve shown is inside of a loop or some RunService step connection.
Rays absolutely would be unsuitable for this, I was more on about
for _, player in ipairs( game.Players:GetPlayers() ) do
if player.Character and player.Character ~= char then
local hrp = player.Character:FindFirstChild( 'HumanoidRootPart' )
local hum = player.Character:FindFirstChild( 'Humanoid' )
if hrp and hum then
if ( hrp.Position - hb.Position ).Magnitude < hb.Size.X / 2 then
hum:TakeDamage( 17 )
end
end
end
end
i was gonna go about it in a way that you would attempt a follow script store every player in a table, then do the magnitude based on that, although it might not handle multiple inputs so maybe i should only make it handle all players and not the closest one.