Im beginner scripter and i made a rain of arrows. As for right now its a lil bit not what i want. Heres the picture of hitbox area that i want to be there. Also theres a problem with damage. Since i used magnitude it takes dmg even if ur behind a wall
heres my current script of hitbox.
if hit.Parent:FindFirstChild("Humanoid") then
hit.Parent:FindFirstChild("Humanoid"):TakeDamage(10)
print(hit)
end
for _,e in pairs(workspace:GetDescendants()) do
if e:FindFirstChild("Humanoid") then
if (arrow.Position - e.HumanoidRootPart.Position).Magnitude < 8 then
e:FindFirstChild("Humanoid"):TakeDamage(5)
if e:FindFirstChild("Humanoid").WalkSpeed > 2 then
local speed = e:FindFirstChild("Humanoid").WalkSpeed
print("SDKDDMDNDMD")
e:FindFirstChild("Humanoid").WalkSpeed = 2
task.delay(1,function()
e:FindFirstChild("Humanoid").WalkSpeed = speed
end)
end
end
else
stuck.Anchored=true
end
end
Maybe do Raycast between arrow.Position and e.HumanoidRootPart.Position when this is true if (arrow.Position - e.HumanoidRootPart.Position).Magnitude < 8?
RaycastParams can be configured to include walls only (that saves some performance I believe).
This way you can get walls between arrows and HumanoidRootPart.
theres a problem. Like to take damage arrow has to hit a person and theres a huge chance that none of them will hit the player so it means theres gonnabe no damage. But i want it to take damage while players are under the rain. like i circled the area (on the posts picture) that i want script take damage if it finds any player there. i want it to work like
if players in area then
while wait(1) do
player.Humanoid:TakeDamage(5)
end
this one script is just like if i have a part then when ppl are touching it they get damage. But i want it work like that: Theres a source part from which arrows are spawning. And i want it damage people by where is it looking at
theres no problem with taking damage if arrow hits the player. Just the hitbox of one arrow is too small and bc of that theres a big chance that u can walk under the rain and dont get any damage