I tried to make a localscript in button which it’s giving badge. I used many tutorials and i don’t know if i have done something wrong?
Because it says: “Sorry, Badges can be only awarded by Roblox Game Awards.”
If it is a gui button then:
Put it in the button as a local script
You need to create a remote event in the Replicated Storage
local Event = game.ReplicatedStorage:WaitForChild("RemoteEvent")
local Button = script.Parent
Button.MouseButton1Down:Connect(function()
Event:FireServer()
end)
Put it in the ServerScriptService as a server script
local Event = game.ReplicatedStorage:WaitForChild("RemoteEvent")
local BadgeService = game:GetService("BadgeService")
local BadgeID = 0000000 -- your badge id
Event.OnServerEvent:Connect(function(Player)
BadgeService:AwardBadge(Player.UserId, BadgeID)
end)
If it is a part then:
You need to create a ClickDetector in the part
local Button = script.Parent.ClickDetector
local badgeservice = game:GetService("BadgeService")
local badgeid = 0000000 -- your badge id
Button.MouseClick:Connect(function(plr)
badgeservice:AwardBadge(plr.UserId, badgeid)
end)
badges can be awarded only from serverscripts.
script.Parent.MouseButton1Click:Connect(function()
game.ReplicatedStorage.Remote:FireServer()
end)
ServerScript :
local BadgeId = 0
local BadgeService = game:GetService("BadgeService")
game.ReplicatedStorage.Remote.OnServerEvent:Connect(function(plr)
if BadgeService:UserHasBadge(player.UserId,BadgeId) then return end -- Checks if the player already has the badge.
plr:AwardBadge(player.UserId,BdageId)
end
end)
Yes that’s why I’m asking if he wants it to be a gui button or a part
if its a gui button you can make a Remote Event to fire to the server and award the badge to the player.
I hope I helped you! If you have more questions message me!
- put in your button
local Button = -- path to button
local GiveBadgeEvent = game:GetService("ReplicatedStorage"):WaitForChild("GiveBadge")
local Id = -- your badge id
local Player = game:GetService("Players").LocalPlayer
Button.MouseButton1Click:Connect(function()
GiveBadgeEvent:FireServer(Id)
end)
- ServerScriptService
local BadgeService = game:GetService("BadgeService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
ReplicatedStorage.GiveBadge.OnServerEvent:Connect(function(Player, Id)
BadgeService:AwardBadge(Player.UserId, Id)
end)
Thank you! It helped me to make endings. Also I am quite confused. Using RemoveEvent, I can make more scripts to give more badges or I need to create more RemoveEvents and scripts to give badge. (It’s for endings)
Sorry, but I am quite bad at speaking English.
It will be easier to understand for you if you will make more Remote Events and just do the same way i told you, basically create another local script inside another gui button.
local Event2 = game.ReplicatedStorage:WaitForChild("RemoteEvent2")
local Button = script.Parent
Button.MouseButton1Down:Connect(function()
Event2:FireServer()
end)
Then where you have your script inside the ServerScriptService just add another BadgeID and another OnServerEvent function
local Event = game.ReplicatedStorage:WaitForChild("RemoteEvent")
local Event2 = game.ReplicatedStorage:WaitForChild("RemoteEvent2")
local BadgeService = game:GetService("BadgeService")
local BadgeID = 0000000 -- your badge id
local BadgeID2= 0000000 -- your another badge id
Event.OnServerEvent:Connect(function(Player)
BadgeService:AwardBadge(Player.UserId, BadgeID)
end)
-- add another OnServerEvent function
Event2.OnServerEvent:Connect(function(Player)
BadgeService:AwardBadge(Player.UserId, BadgeID2)
end)
ok. thank you so much! i will remember this.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.