of     1   

PancakeChop
#169852426Monday, August 03, 2015 10:47 PM GMT

I want to affect the players close to me in a script, but is there a way in Roblox Lua to do that?
ShungTzu
#169852642Monday, August 03, 2015 10:49 PM GMT

PancakeChop
#169852736Monday, August 03, 2015 10:50 PM GMT

What about magnitude?
buildersteven4
#169852739Monday, August 03, 2015 10:50 PM GMT

^ don't
buildersteven4
#169852789Monday, August 03, 2015 10:51 PM GMT

woops. yes use magnitude
buildersteven4
#169852933Monday, August 03, 2015 10:52 PM GMT

if (torso1.Position - torso2.Position).magnitude < range then -- the player is close, MURDER HIM :D end
WoolHat
#169853257Monday, August 03, 2015 10:56 PM GMT

You'd need a while true loop on that. Just curious, would that cause much lag at all? and, with different wait times, will it cause more/less?
PancakeChop
#169853640Monday, August 03, 2015 11:00 PM GMT

Can you just make a quick example of printing the nearest Torso to my player?
buildersteven4
#169853681Monday, August 03, 2015 11:00 PM GMT

It's not a laggy operation. Especially since there are only a few players in a game at any given moment. the longer you make the waiting time the less CPU intense it is. so wait() might be a bit overkill. (but might not be in some cases)
buildersteven4
#169854544Monday, August 03, 2015 11:11 PM GMT

I guess I gone a bit overkill with all the checks... whatever! here you have it! (haven't tested it so beware of typo's) function nearestPlayer(player) if player.Character then local torso = player.Character:FindFirstChild("Torso") if torso:IsA("BasePart") then local position = torso.Position local nearestDistance = math.huge local nearestPlayer for _, curPlayer in pairs(game.Players:GetPlayers()) do if curPlayer ~= player and curPlayer.Character then local curTorso = curPlayer.Character:FindFirstChild("Torso") if curTorso:IsA("BasePart") then local curDistance = (curTorso.Position - position).magnitude if curDistance < nearestDistance then nearestDistance = curDistance nearestPlayer = curPlayer end end end end return nearestPlayer end end end
R1_SK
#169854947Monday, August 03, 2015 11:15 PM GMT

free bump

    of     1