Hi, We making some games, like our game called ProjectX. We have an account on FreshCut and want to celebrate our first 330 subscribers achievement. So, to do that, we started a giveaway, which ends in 9 days, and to participate, you need to type any feedback in our game with tag #freshcutgiveaway. After that, I got an idea, to do a badge, that player receive if type any feedback with this hashtag, but I don’t know how to do it.
Can anyone help?
Please, can anyone help? I need to know it too much
By:
do you mean say the tag when chatting in your game? If yes, does your game use TextChatService or the legacy chat?
No, I created my own gui in game, where you can type any feedback, and it’s will be sended to my Guilded via webhook.
Unfortunately I won’t be able to help you with the part about your webhook since I lack knowledge and experience with that area, but I can at least provide a solution to your badge problem and the steps are:
- Create a RemoteEvent inside of ReplicatedStorage. For the sake of testing I left its name to default which is “RemoteEvent”
- Add a LocalScript as a child of the TextBox. Inside of it write:
--!strict
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local textBox = script.Parent
local remoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")
local function onFocusLost(enterPressed: boolean)
if enterPressed then
if string.find(textBox.Text, "#freshcutgiveaway") then remoteEvent:FireServer() end
end
end
textBox.FocusLost:Connect(onFocusLost)
- Add a server Script inside of ServerScriptService and inside of it write:
--!strict
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local BadgeService = game:GetService("BadgeService")
local BADGE_ID = 1234567890 -- Replace this value with your actual badge ID
local remoteEvent = ReplicatedStorage.RemoteEvent
local function onServerEvent(player: Player)
local success, badgeInfo = xpcall(BadgeService.GetBadgeInfoAsync, warn, BadgeService, BADGE_ID)
if success then
if badgeInfo.IsEnabled then
local success, userHasBadge = xpcall(BadgeService.UserHasBadgeAsync, warn, BadgeService, player.UserId, BADGE_ID)
if success then
if userHasBadge then return end
xpcall(BadgeService.AwardBadge, warn, BadgeService, player.UserId, BADGE_ID)
end
else
warn("Unable to award badge because it's currently disabled")
end
end
end
remoteEvent.OnServerEvent:Connect(onServerEvent)
Thanks for the answer, but it’s not giving the badge
Is this being printed in your output: Unable to award badge because it's currently disabled
. If yes, then that means you need to wait a bit while Roblox processes your badge and enables it
No, I have it enabled, and I just updated my another badge that I already have, but deleted it from inventory
Do you have any warnings in your output? If yes, what do they say and on which line are they occurring?
I rewrited script in SSS to:
local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local BADGE_ID = 2979174096356303 – Replace this value with your actual badge ID
local remoteEvent = ReplicatedStorage.Remotes:WaitForChild(“FreshCutGiveawayBadge”)remoteEvent.OnServerEvent:Connect(function(Player)
if not game.BadgeService:UserHasBadgeAsync(Player.UserId, BADGE_ID) then
game.BadgeService:AwardBadge(Player.UserId, BADGE_ID)
end
end)
but it also doesn’t work
Out of curiosity, do you already own the badge yourself? The script I wrote won’t award the badge to a player that already owns it so for testing you’ll need to remove the badge from your inventory before you test it
And also tried to change Local function in TextBox’s script to just a function, but it also doesn’t work (here’s script):
local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local textBox = script.Parent
local remoteEvent = ReplicatedStorage.Remotes:WaitForChild(“FreshCutGiveawayBadge”)function onFocusLost(enterPressed: boolean)
if enterPressed then
if string.find(textBox.Text, “#freshcutgiveaway”) then remoteEvent:FireServer() end
end
endtextBox.FocusLost:Connect(onFocusLost)
No, I don’t have anything on it
I also tried to type #freshcutgiveaway only, but it also doesn’t give me the badge
I’d recommend that you refrain from modifying the scripts unless absolutely necessary (for example the BADGE_ID
and the name of the RemoteEvent are ok to modify)
I’m saying this because I noticed the server script you sent me is vastly different than the one I gave you
It’s should to work, because script should to give you the badge when you’re firing remoteevent, but it’s not
So, the main problem why it’s not working is being on this script:
local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local textBox = script.Parent
local remoteEvent = ReplicatedStorage.Remotes:WaitForChild(“FreshCutGiveawayBadge”)
function onFocusLost(enterPressed: boolean)
if enterPressed then
if string.find(textBox.Text, “#freshcutgiveaway”) then remoteEvent:FireServer() end
end
endtextBox.FocusLost:Connect(onFocusLost)
I noticed you weren’t using :WaitForChild
for the Remotes folder so try changing the LocalScript to:
--!strict
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local textBox = script.Parent
local remoteEvent = ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("FreshCutGiveawayBadge")
local function onFocusLost(enterPressed: boolean)
if enterPressed then
if string.find(textBox.Text, "#freshcutgiveaway") then remoteEvent:FireServer() end
end
end
textBox.FocusLost:Connect(onFocusLost)
It’s can be becouse of enterPressed part on 7, 8th lines