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

Why is this function going off when it's not being called?

Asked by
4D_X 118
5 years ago
function FindPlr(a, plr)
    local a = false
    for i,v in pairs(game.Players:GetPlayers()) do
        if string.find(string.lower(string.sub(v.Name,1,string.len(plr))),string.lower(plr),1,false) and plr ~= "" then
            a = v.Name
        end
        end
    return a
end
Functions.FindPlr.OnServerInvoke = FindPlr()

It's not being invoked though..........

1 answer

Log in to vote
1
Answered by 5 years ago

If you put parenthesis () after a function, it will always run. To fix it just remove it, as you want it to store the function, not the value it returns.

Functions.FindPlr.OnServerInvoke = FindPlr
0
Thanks... I'm stupid haha 4D_X 118 — 5y
0
No problem. We all make silly mistakes every now and then ;) SirDerpyHerp 262 — 5y
Ad

Answer this question