Hello, I know that I'm close to solving magnitude but I don't understand how to fix this (If player is within 10 studs of brick in Workspace, kill them.):
local a = game.Workspace.P1 game.Players.ChildAdded:connect(function(Player) if Player then if game.Workspace:FindFirstChild(Player.Name) then local Char = Player.Character local Tors = Char:WaitForChild("Torso") while true do if (a.Position - Tors.Position).magnitude < 10 then Char:BreakJoints() wait(.01) end wait(.01) end end end end)
I can't tell any problems with your magnitude check, but there are some other pieces you may want to de-ew that may work on. Here I'm going to wait until the character exists, and actually take damage on the player.
local a = game.Workspace.P1 game.Players.ChildAdded:connect(function(Player) if Player then repeat wait() until game.Workspace:FindFirstChild(Player.Name) local Char = Player.Character local Tors = Char:WaitForChild("Torso") while wait() do if (a.Position - Tors.Position).magnitude < 10 then Char.Humanoid:TakeDamage(Char.Humanoid.Health) end wait() end end end end)
If this helped, make sure to accept and upvote!
~Chem