Everything is tagged correctly, and i want it to also kill them if they are withing 5 studs of me I am only giving the chunk with the ray of my code.
ray = Ray.new(char.Torso.Position,Vector3.new(5,5,5)) coroutine.resume(coroutine.create(function() while wait() do if pent.Parent == game.Workspace then hit = Workspace:FindPartOnRay() print(hit.Name) if hit and hit.Parent:findFirstChild("Humanoid") then hit.Humanoid.Health = 0 end end end end))
To be honest, I don't have knowledge of Rays, but you can get the Radius by doing a simple formula.
-- LocalScript, Inside a player's playergui or backpack or character. local radius = 10 local player = Game:GetService("Players").LocalPlayer repeat wait() until player.Character local t=player.Character:WaitForChild("Torso") coroutine.resume(coroutine.create(function() while wait(.05) do --Lag must be prevented, I suggest you to use wait() wisely. for _,v in ipairs(Workspace:GetChildren() do if v.ClassName=="Model" then -- Making sure it's a character model. if Game.Players:GetPlayerFromCharacter(v) then -- Making sure it's a true player. local t2=v:FindFirstChild("Torso") if t2 then if (t.Position-t2.Position).Magnitude<=radius then --Formula t2:BreakJoints() end end end end end end end))