Answered by
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:
01 | local BadgeService = game:GetService( "BadgeService" ) |
03 | local function awardBadge(player, badgeId) |
05 | local success, badgeInfo = pcall ( function () |
06 | return BadgeService:GetBadgeInfoAsync(badgeId) |
11 | if badgeInfo.IsEnabled then |
13 | local success, result = pcall ( function () |
14 | return BadgeService:AwardBadge(player,badgeId) |
19 | warn( "Error while awarding badge:" , result) |
20 | elseif not result then |
22 | warn( "Failed to award badge." ) |
27 | warn( "Error while fetching badge info: " .. badgeInfo) |
32 | machine.SuperJPSensor.Touched:Connect( function (hit) |
33 | if hit.Name = = "Neptune_Ball" then |
37 | awardBadge(game.Players:FindFirstChild(machine.CardReader.GameInfo.Player.Value), 2126911393 ) |
38 | machine.Particle.ParticleEmitter.Enabled = true |
39 | sounds.MonsterJackpot 2 :Play() |
41 | sounds.MonsterDropMonsterJackpotSong:Play() |
42 | ticketOut(machine.MegaJackpotScreen.Value.Value) |
44 | machine.MegaJackpotScreen.SurfaceGui.Enabled = true |
45 | for _,a in pairs (SideLights:GetChildren()) do a.SurfaceLight.Enabled = true ; a.Material = Enum.Material.Neon end |
47 | for _,a in pairs (SideLights:GetChildren()) do a.SurfaceLight.Enabled = false ; a.Material = Enum.Material.SmoothPlastic end |
48 | machine.MegaJackpotScreen.SurfaceGui.Enabled = false |
51 | machine.MegaJackpotScreen.Value.Value = MegaJPDefault |
52 | for _,a in pairs (SideLights:GetChildren()) do a.SurfaceLight.Enabled = true ; a.Material = Enum.Material.Neon end |
54 | sounds.MonsterJackpot 2. Volume = i |
57 | sounds.MonsterDropMonsterJackpotSong:Stop() |
58 | machine.Particle.ParticleEmitter.Enabled = false |
This code is a bit messy, so idk it it will work. And Ceebeebies is not poo, I LOVE it :)