Hello, currently making a “luck” based game. Basically one of thoughs games where you have a chance to win a small amount of robux. For losing you get a badge called “Better luck next time” and for winning the highest amount you also get a badge. I have tried many ways of getting this to work, but none have worked. I am currently stuck at this, which is a script within ServerScriptService.
local Players = game:GetService("Players")
local badgeService = game:GetService("BadgeService")
Players.PlayerAdded:Connect(function(player)
local l = player.PlayerGui:WaitForChild("ScreenGui").RewardFrame.Reward
local playerName = player.Name
print(l.Text)
if l.Text == "Congratulations, "..playerName.." You won 1,000 Robux! DM hryg on Discord to claim! Please send a screenshot as proof!" then
local badgeId = 2148268031 -- ID of the "1,000 Robux Winner" badge
badgeService:AwardBadge(player.UserId, badgeId)
end
if l.Text == "Hey, "..playerName.." We're sorry but you didn't win anything this time! Feel free to try again!" then
local badgeId = 2148267957 -- ID of the "No Prize" badge
badgeService:AwardBadge(player.UserId, badgeId)
end
end)
This script is checking a GUI’s text as soon as they join the game from the server side.
How are they being awarded this? Because if it’s as soon as they join the game then you should handle everything server side and then send a RemoteEvent to the client telling it to update the GUI with a message of them winning or losing.
You should really never be checking the text of a GUI from the server.