Can badge service only be used in a server script? How would i make it so it can be called from a local script?
You can only award badges through server scripts.
You can use remotes/module scripts for that.
[But lets say you wanted to award player a badge for pressing a textbutton, all you have to do is fire a remote inside the mousebutton1click event, and on the server, award him].
Well what would be using this for? When a player touches a part, or clicks a button?
what if it was touched event?
blank space
i would be doing it for a touched event. Sorry i did not specify that.
Sure you can, if it’s a local script, just use a remote.
[On the server make sure to use pcalls to check if the player doesnt have the badge already]
See this for more info:
https://devforum.roblox.com/t/badge-scripts-compilation/1727148
I don’t see a remote event being used in the part section of the post…
Here is some code:
script.Parent.Touched:Connect(function(part)
if part.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(part.Parent)
game:GetService("BadgeService"):AwardBadge(player.UserId, -- your badge ID )
end
end)
If you need more explaining, here is the tutorial
Make sure to use pcalls to validate if the player doesnt own the badge already, there’s always a chance of failing.
would it be like:
game.Workspace.Part.Touched:Connect(function(Hit)
game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connnect(function(Player)
--Badge stuff
end)
end)
Pcalls included in badge stuff
Yes. But make sure to check if the object that touched the brick is a player. And make sure to check by using pcalls if the player already has the badge.
game.Workspace.Part.Touched:Connect(function(Hit)
--Check it was a player
--Use pcalls to check if he owns the badge or not
--ONLY if he doesnt, then fire this
game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connnect(function(Player)
--And here you can simply award him[since we checked up]
end)
end)
the get service perameter will be in
You’ll use game.Players:GetPlayerFromCharacter(Hit.Parent)
After you checked if the object has a humanoid.
And with that, you’ll be able to use your pcalls and provide the player’s ID by getting his ID from his name or straight from players/
but the badge service call will be in
right?
local BadgeService = game:GetService("BadgeService")
local BadgeId = 0000000
--These 2 will help you later on in the pcalls
local userHasBadge = BadgeService.UserHasBadgeAsync
local awardBadge = BadgeService.AwardBadge
game.Workspace.Part.Touched:Connect(function(Hit)
--Check it was a player
--Use pcalls to check if he owns the badge or not
--ONLY if he doesnt, then fire this
game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connnect(function(Player)
--And here you can simply award him[since we checked up]
end)
end)
oh okay. Thanks. Learned quite a lot 
[I linked above a compilation where you can use the way he used pcalls there]
No problems
Glad I could help.
If something goes wrong, feel free to say here to dm.
Could an IF statement work? If so, I already have the code for it, and it works just fine.
Not enough, when working with such services, [checking for group ranks too], you should use pcalls to make sure that even when it fails, dont let it get down.