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

How can i give players badge whenever i'm at the server?

Asked by 6 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 6 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)

Please accept the answer if it helped!

0
Thanks! Works. Velege1 2 — 6y
0
No problem :) Michael_TheCreator 166 — 6y
Ad

Answer this question