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

ServerScriptService.AddPointCommand:7: invalid argument #1 to 'lower' (string expected, got nil) ?

Asked by
lomo598 -7
3 years ago

I am trying to fix this problem above.

Here is my script:

local GroupId = 00 local MinimumRankToUseCommand = 00

function Caps(PartialName) local foundName = nil local Players = game.Players:GetPlayers() for i, player in pairs(Players) do if string.find(string.lower(player.Name), string.lower(PartialName)) then foundName = player.Name end end

if not foundName then
    return nil
else
    return foundName
end

end

game.Players.PlayerAdded:Connect(function(Player) if Player:GetRankInGroup(GroupId) >= MinimumRankToUseCommand then Player.Chatted:Connect(function(Message) local Words = string.split(Message, " ")

        if Words[1] == "Pass" then
            local NameOfPlayerToGivePoint = Words[2]

            local PlayerToGivePoint = game.Players:FindFirstChild(NameOfPlayerToGivePoint)

            if NameOfPlayerToGivePoint  ~= "" then
                local PointGiver = Caps(PlayerToGivePoint)
                if PointGiver then
                    PointGiver.leaderstats.Points.Value = PointGiver.leaderstats.Points.Value + 1

                end
            end
        end
    end)
end

end)

Answer this question