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

I am trying to make this give out a badge when youwin the mega jackpot but it wont give it out?

Asked by 2 years ago
01`machine.SuperJPSensor.Touched:Connect(function(hit) -- Registers the ball reaching the Mega Jackpot hole
02    if hit.Name == "Neptune_Ball" then
03        muteMusic()
04        local BadgeService = game:GetService("BadgeService")
05 
06        local function awardBadge(player, badgeId)
07            -- Fetch badge information
08            local success, badgeInfo = pcall(function()
09                return BadgeService:GetBadgeInfoAsync(badgeId)
10            end)
11 
12            if success then
13                -- Confirm that badge can be awarded
14                if badgeInfo.IsEnabled then
15                    -- Award badge
View all 55 lines...

game.Players:FindFirstChild(machine.CardReader.GameInfo.Player.Value is the player playing the game

0
You could just use a teleport script to teleport them to a part that gives badge on touch. That would make it easier probably VipDanT 10 — 2y
0
That would be stupid because you get 5 plays per swipe cbeebiespoo -5 — 2y
0
I have fixed my answer sleazel 1287 — 2y

1 answer

Log in to vote
0
Answered by
sleazel 1287 Moderation Voter
2 years ago
Edited 2 years ago

So You are declaring the awardBadge function (with the lowercase a), but You never call it. On top of that it is rather unfeasible to declare it inside the anonymous touched function. Do not nest function declarations, unless You really really know what You are doing.

The second problem is at the AwardBadge call (with the upppercase A). AwardBadge is the function of BadgeService and should be called like this BadgeService:AwardBadge(...)

Here is Your script:

01local BadgeService = game:GetService("BadgeService")
02 
03local function awardBadge(player, badgeId)
04            -- Fetch badge information
05            local success, badgeInfo = pcall(function()
06                return BadgeService:GetBadgeInfoAsync(badgeId)
07            end)
08 
09            if success then
10                -- Confirm that badge can be awarded
11                if badgeInfo.IsEnabled then
12                    -- Award badge
13                    local success, result = pcall(function()
14                        return BadgeService:AwardBadge(player,badgeId) --use passed arguments
15                    end)
View all 60 lines...

This code is a bit messy, so idk it it will work. And Ceebeebies is not poo, I LOVE it :)

0
the celebration works just wont hand the badge out cbeebiespoo -5 — 2y
Ad

Answer this question