##Problem
What the script thinks you're doing is running a function on the keyword string. When you try calling a function in a table with ":" the script will assume you're calling the function with the table itself being the first argument. That's why you may see
tab = {
i = 'Hello';
p = function(self)
print(self.i)
end }
tab:p()
Or method similar to this. The script should end up printing the i variable. What "string" is, is basically an array of functions that is a keyword for all scripts.
##Solution
You can go two ways.
- Actually call the
StringOrStringVariableHere:len() function on the actual string itself.
- Or use
string.len(StringOrStringVariableHere)
##Final Script
function getPlayer(str)
local plyr = {}
str = str:lower()
local l = string.len(str)
for i,v in pairs(game.Players:children()) do
if v:IsA("Player") then
if v.Name:sub(1, l) == str then
plyr = v
end
end
end
end
######Hope this helped. If you have any questions feel free to comment below.
2 comments
That fixed the error I was having, but now it won't recognize it as a player as it's a table. So I can't run :GetRankInGroup() or, for killing, having it do plyr.Character
Why not on line 8 just return the v variable and for the kill script do something like getPlayers(stringhere).Character:BreakJoints(). I can not help you in many other parts of the script if I can not see them.