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

The Code That I am making is not working and I don't know why?

Asked by
VipDanT 10
1 year ago

so I have this code that is suppose to give a badge when the word "/nuke" is said by me, but it doesnt work! Anyone know why?
admin = {"VipDanT"}

if admin.Chatted "/nuke" then local badgeservice = game:GetService("BadgeService") local badgeId = 2128480065 local Players = game:GetService("Players")

local function giveBadges(id) -- allows you to call giveBadges (with the ID as the first parameter) to give every player in the server a badge.
    for i, player in pairs(Players:GetPlayers()) do
        badgeservice:AwardBadge(player.UserId , id)
    end
end

giveBadges(badgeId)

end

0
did you view the output or the dev console to see any errors that might hint at it? D00M1N 4 — 1y
0
I looked but nothing showed VipDanT 10 — 1y

1 answer

Log in to vote
0
Answered by 1 year ago

I took a decent look at that script and it seemed like your attempt to call the "chatted" function was wrong. This is how I usually do it.

admin = {"VipDanT"}
game.Players.PlayerAdded:Connect(function(plr)
    plr.Chatted:Connect(function(msg)
    if table.find(admin, plr.Name) then
        if msg == "/nuke" then 
            local badgeservice = game:GetService("BadgeService") 
            local badgeId = 2128480065 
            local Players = game:GetService("Players")
            local function giveBadges(id)
            for i, player in pairs(Players:GetPlayers()) do
                badgeservice:AwardBadge(player.UserId , id)
            end
            end
            giveBadges(badgeId)
        end
    end
    end)
end)

That was the only error I could see in your script. Hopefully this one works out for you!

0
Thank you Taxicar24! VipDanT 10 — 1y
Ad

Answer this question