I’m not aware if thus is possible, but here it goes anyway. Anyone know if there is a way to make a player lose health if they come into a certain distance from a part? This is without using a hitbox for detection.
Yes there’s a way to do that
local waitvalue = 1 -- Time to wait each time for dealing damge local damage = 10 --Damage dealt local maxdistance = 25 -- Max studs between the part and the character while wait(waitvalue) do for e,char in pairs(workspace:GetChildren()) do if char:FindFirstChildWhichIsA("Humanoid") and (script.Parent.Position - char:WaitForChild("HumanoidRootPart").Position).Magnitude <= maxdistance then char:FindFirstChildWhichIsA("Humanoid"):TakeDamage(damage) print((script.Parent.Position - char:WaitForChild("HumanoidRootPart").Position).Magnitude) end end end
Place this script in the part
Thanks a bunch! I marked Solution!
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.