Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make a player finder script which uses magnitude to add a object value to a folder?

Asked by 5 years ago
Edited 5 years ago

My code is this the name of the script is player finder

01local Attacks = require(script.Parent.Attacks)
02game.Players.PlayerAdded:Connect(function(plr)
03    wait(3)
04    plr.CharacterAdded:Connect(function(char)
05        local Torso = char:FindFirstChild("Torso") or char:FindFirstChild("UpperTorso")
06        local mag = (Torso.Position - script.Parent.UpperTorso.Position)
07        while wait() do
08            if mag >= 23 then
09                if not Attacks:IsPlayerHere(plr.Name) then
10    local obj = Instance.new("ObjectValue")
11    obj.Value = plr
12    obj.Name = plr.Name --Name doesn't matter
13    obj.Parent = script.Parent.Players
14    end
15    end
16    end
17    end)
18end)

it's supposed to add a value to a folder and the module script has a player checking system and returns true or false

1local Attacks = {}
2function Attacks:IsPlayerHere(plrinquestion)
3if script.Parent.Players:FindFirstChild(plrinquestion) then
4return true
5else
6return false
7end

is the loop not working for the magnitude?

0
(Torso.Position - script.Parent.UpperTorso.Position).magnitude fredfishy 833 — 5y
0
lol fixed 1TheLeaf 2 — 5y

Answer this question