Hello, I’m Omari and I’d appreciate it if you could help me solve this problem I’ve run into. To keep it short, I have this Dialog Object inside the head of my NPC that is supposed to reward players with a badge upon interacting with them. I’ve tried using Roblox Studio-related Discord servers before coming here but had no luck.
Script: local BADGE_ID = 317477210837505 local head = script.Parent:WaitForChild(“Head”) local dialog = head:WaitForChild(“Dialog”) local BadgeService = game:GetService(“BadgeService”) local Players = game:GetService(“Players”) local function awardBadge(player) if not player then print(“No player found”) return end local playerId = player.UserId local success, hasBadge = pcall(function() return BadgeService:UserHasBadgeAsync(playerId, BADGE_ID) end) if success and hasBadge then print(player.Name … " already has the badge.") else local awarded = pcall(function() BadgeService:AwardBadge(playerId, BADGE_ID) end) if awarded then print("Awarded badge to " … player.Name) else warn("Failed to award badge to " … player.Name) end end end dialog.DialogChoiceSelected:Connect(function(player) print(“DialogChoiceSelected triggered”) print(“Player:”, player) local playerObject = Players:GetPlayerFromCharacter(player.Parent) if playerObject then print("Player object found: " … playerObject.Name) awardBadge(playerObject) else warn(“Player object not found.”) end end) print(“Dialog script initialized”)