`machine.SuperJPSensor.Touched:Connect(function(hit) -- Registers the ball reaching the Mega Jackpot hole if hit.Name == "Neptune_Ball" then muteMusic() local BadgeService = game:GetService("BadgeService") local function awardBadge(player, badgeId) -- Fetch badge information local success, badgeInfo = pcall(function() return BadgeService:GetBadgeInfoAsync(badgeId) end) if success then -- Confirm that badge can be awarded if badgeInfo.IsEnabled then -- Award badge local success, result = pcall(function() return AwardBadge(game.Players:FindFirstChild(machine.CardReader.GameInfo.Player.Value), 2126911393) end) if not success then -- the AwardBadge function threw an error warn("Error while awarding badge:", result) elseif not result then -- the AwardBadge function did not award a badge warn("Failed to award badge.") end end else warn("Error while fetching badge info: " .. badgeInfo) end end machine.Particle.ParticleEmitter.Enabled = true sounds.MonsterJackpot2:Play() wait(2) sounds.MonsterDropMonsterJackpotSong:Play() ticketOut(machine.MegaJackpotScreen.Value.Value) for i = 1, 200 do machine.MegaJackpotScreen.SurfaceGui.Enabled = true for _,a in pairs(SideLights:GetChildren()) do a.SurfaceLight.Enabled = true; a.Material = Enum.Material.Neon end wait(0.1) for _,a in pairs(SideLights:GetChildren()) do a.SurfaceLight.Enabled = false; a.Material = Enum.Material.SmoothPlastic end machine.MegaJackpotScreen.SurfaceGui.Enabled = false wait(0.1) end machine.MegaJackpotScreen.Value.Value = MegaJPDefault for _,a in pairs(SideLights:GetChildren()) do a.SurfaceLight.Enabled = true; a.Material = Enum.Material.Neon end for i = 2, 0, -0.2 do sounds.MonsterJackpot2.Volume = i wait(0.1) end sounds.MonsterDropMonsterJackpotSong:Stop() machine.Particle.ParticleEmitter.Enabled = false end end)`
game.Players:FindFirstChild(machine.CardReader.GameInfo.Player.Value is the player playing the game
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:
local BadgeService = game:GetService("BadgeService") local function awardBadge(player, badgeId) -- Fetch badge information local success, badgeInfo = pcall(function() return BadgeService:GetBadgeInfoAsync(badgeId) end) if success then -- Confirm that badge can be awarded if badgeInfo.IsEnabled then -- Award badge local success, result = pcall(function() return BadgeService:AwardBadge(player,badgeId) --use passed arguments end) if not success then -- the AwardBadge function threw an error warn("Error while awarding badge:", result) elseif not result then -- the AwardBadge function did not award a badge warn("Failed to award badge.") end end else warn("Error while fetching badge info: " .. badgeInfo) end end machine.SuperJPSensor.Touched:Connect(function(hit) -- Registers the ball reaching the Mega Jackpot hole if hit.Name == "Neptune_Ball" then muteMusic() --add this line, and pass arguments here --error fixed awardBadge(game.Players:FindFirstChild(machine.CardReader.GameInfo.Player.Value), 2126911393) machine.Particle.ParticleEmitter.Enabled = true sounds.MonsterJackpot2:Play() wait(2) sounds.MonsterDropMonsterJackpotSong:Play() ticketOut(machine.MegaJackpotScreen.Value.Value) for i = 1, 200 do machine.MegaJackpotScreen.SurfaceGui.Enabled = true for _,a in pairs(SideLights:GetChildren()) do a.SurfaceLight.Enabled = true; a.Material = Enum.Material.Neon end wait(0.1) for _,a in pairs(SideLights:GetChildren()) do a.SurfaceLight.Enabled = false; a.Material = Enum.Material.SmoothPlastic end machine.MegaJackpotScreen.SurfaceGui.Enabled = false wait(0.1) end machine.MegaJackpotScreen.Value.Value = MegaJPDefault for _,a in pairs(SideLights:GetChildren()) do a.SurfaceLight.Enabled = true; a.Material = Enum.Material.Neon end for i = 2, 0, -0.2 do sounds.MonsterJackpot2.Volume = i wait(0.1) end sounds.MonsterDropMonsterJackpotSong:Stop() machine.Particle.ParticleEmitter.Enabled = false end end)
This code is a bit messy, so idk it it will work. And Ceebeebies is not poo, I LOVE it :)