local badgeservice = game:GetService("BadgeService") local id = 2128449719 local part = script.Parent local detector = part.ClickDetector detector.MouseClick:Connect(function(player) print("clicked") local plr = game.Players:GetPlayerFromCharacter(hit.Parent) badgeservice:AwardBadge(plr.UserId, id) end)
im attempting to give a player a badge when clicking an object. However when testing in Roblox Studio's test area, nothing occurs. I have added a ClickDetector as a child to said object as well, i haven't forgotten.
I see a problem. You have the parameters of the connection as 'player', yet you try to use 'hit.Parent', even though it is never defined. Clickdetector.MouseClick returns the player who clicked as params, so you don't need getplayerfromchar, just remove the line (08) and it should work
remember to change badgservice params to player.userid, id