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

local Attacks = require(script.Parent.Attacks)
game.Players.PlayerAdded:Connect(function(plr)
    wait(3)
    plr.CharacterAdded:Connect(function(char)
        local Torso = char:FindFirstChild("Torso") or char:FindFirstChild("UpperTorso")
        local mag = (Torso.Position - script.Parent.UpperTorso.Position)
        while wait() do
            if mag >= 23 then
                if not Attacks:IsPlayerHere(plr.Name) then
    local obj = Instance.new("ObjectValue")
    obj.Value = plr
    obj.Name = plr.Name --Name doesn't matter
    obj.Parent = script.Parent.Players
    end
    end
    end
    end)
end)

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

local Attacks = {}
function Attacks:IsPlayerHere(plrinquestion)
if script.Parent.Players:FindFirstChild(plrinquestion) then
return true
else
return false
end

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