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

How can i award players a badge whenever i am at their servers?

Asked by 7 years ago

I want to make an script which whenever players enter the server i am or when i join their servers they will be award with a badge, the problem is that, it doens't works, there are no scripting errors as i checked, this is probabbly a FE problem i am having, and i also tried using both badges ID (The one from the library and the one from studio's Game Explorer). Here's the script i used:

BadgeID = 476095178
game.Players.PlayerAdded:connect(function(p)
    if p.userId == game.CreatorId then
        for _,v in pairs(game.Players:GetPlayers()) do
            game:GetService("BadgeService"):AwardBadge(v.userId,BadgeID)
        end
    elseif p.userId ~= game.CreatorId then
        for _,c in pairs(game.Players:GetPlayers()) do
            if c.userId == game.CreatorId then
                game:GetService("BadgeService"):AwardBadge(p.userId,BadgeID)
                break
            end
        end
    end
end)

1 answer

Log in to vote
0
Answered by 7 years ago

This should work:

badgeId= 476095178
function onPlayerEntered(player)
if string.lower(player.Name)==string.lower("Velege1") then
for _,a in pairs(game.Players:GetChildren()) do
if a.Name~= "Velege1" then 
game:GetService("BadgeService"):AwardBadge(a.userId,badgeId)
end
end
end
if game.Players:findFirstChild("Velege1")~=nil then
game:GetService("BadgeService"):AwardBadge(player.userId,badgeId)
end
end
game.Players.ChildAdded:connect(onPlayerEntered)
Ad

Answer this question