Hello everyone!
So I have a game, and I'm trying to make it so a player receives a badge when they have over 1,000 EXP.
Now I'm not good at scripting, but I tried to script it anyways. It didn't work.
Can someone help me with this, please?
local badgeId = 1390726909 local badgeService = game:GetService("BadgeService") local function onEntered(player) wait(5) local hum = player:FindFirstChild("Humanoid") if hum then if player.leaderstats.EXP.Value<=1000 then badgeService:AwardBadge(player.userId, badgeId) end end end game.Players.PlayerAdded:connect(onEntered)
Assuming you already have a script to create the EXP leaderstat, you can try something like this which will check every time the EXP changes.
local badgeId = 1390726909 local badgeService = game:GetService("BadgeService") local function onEntered(player) player:WaitForChild("leaderstats"):WaitForChild("EXP").Changed:Connect(function(newExp) if newExp >=1000 then if not badgeService:UserHasBadge(player.UserId,badgeId) then badgeService:AwardBadge(player.userId, badgeId) end end end) end game.Players.PlayerAdded:connect(onEntered)
Also, Humanoid isn't inside of the player, it's inside of the character. However, with PlayerAdded you shouldn't need to do this check.
This only fires when the player joins the game, not sure if this is what you're going for. You also have the greater than value flipped. Line 8 should look like
if player.leaderstats.EXP.Value>=1000 then
This is if you want it to be greater than or equal to 1000. Hope this helped.