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

What is wrong with this script? D: [FIXED QUESTION]

Asked by
Zequew 0 Donator
9 years ago

Apparently my friend gave me a BadgeGiver Script and it wont work when I say the command.. Here is the script below!!

speakers =  {"Zequew"} 
function checkSpeakers(name)
    for i,v in pairs(speakers) do
                if (string.upper(name) == string.upper(v)) then return true end
        end
        return false
end
function matchPlayer(str)
    local result = nil
    local players = game.Players:GetPlayers()
    return result
end
function onChatted(msg, recipient, speaker)
    local source = string.lower(speaker.Name)
    msg = string.lower(msg)
    if (string.find(msg, ":Badge") == 1) then
        for word in msg:gmatch("%w+") do 
            local p = matchPlayer(word)
    for i,v in pairs(game.Players:GetPlayers()) do
        if (string.find(string.lower(v.Name), str) == 1) then
            if (result ~= nil) then return nil end
            result = v
        end
    end
            if (p ~= nil) then
                print("Awarding BadgeID: " ..script.BadgeID.Value .. " to UserID: " .. p.userId)
                local b = game:GetService("BadgeService")
                b:AwardBadge(p.userId, script.BadgeID.Value)
            end
        end
    end
end
function onPlayerEntered(newPlayer)
    if checkSpeakers(newPlayer.Name) then
        newPlayer.Chatted:connect(function(msg, recipient) onChatted(msg, recipient, newPlayer) end) 
    end
end
game.Players.PlayerAdded:connect(onPlayerEntered)

**on that script there is a thing on it I will take a picture for you! Picture: http://gyazo.com/e8afaaf4b335a0d7b53b8702fcaba461

Can someone please tell me on what is wrong with it? I would be greatly appreciated.

**

Answer this question