Receive badge when clicking on textbutton (Solved Myself)

So I want to do that when you click on a TextButton you get a Badge, I’ve tried multiple scripts but it didn’t work, so I would appreciate some help! However the gui is inside a script in ServerScriptService so it makes it that one person sees the gui.

You can add a LocalScript inside the button in the Gui that is being cloned to the PlayerGui.

local BadgeService = game:GetService("BadgeService")
local Player = game:GetService("Players").LocalPlayer

local button = script.Parent

button.MouseButton1Click:Connect(function() --When the button is clicked
   BadgeService:AwardBadge(Player.UserId, BadgeID) --Awards the badge to the player

Doesn’t work.


Any errors?
What does’nt works? The badge is not being awarded or the click is not being detected?