I've made a badge that players get if they've been in the game for over an hour. Problem is, the script for it doesn't work. It keeps warning me with this message: "Sorry, badges can only be awarded by Roblox game servers." so I double checked, and the script was indeed a server script running inside the game. It was under ServerScriptService, which I don't think should have affected anything. The script is here:
local players = game:GetService("Players")
local repStorage = game:GetService("ReplicatedStorage")
local timeEvent = repStorage:WaitForChild("getPlayerTime")
local folder = script.ClientTimes
players.PlayerAdded:Connect(function(plr)
local val = Instance.new("NumberValue")
val.Name = plr.Name.."Time"
val.Value = 0
val.Parent = folder
local newThread = coroutine.wrap(function()
while val do
wait()--.98)
val.Value = val.Value + 10 --usually it waits .98 seconds and adds 1 second, but I wasn't going to wait an hour to test a badge
print(val.Value/60/60)
if val.Value/60/60 > 1 then
game:GetService("BadgeService"):AwardBadge(plr.UserId, 1640722449)
end
end
end)
newThread()
end)
players.PlayerRemoving:Connect(function(plr)
local oldval = folder:FindFirstChild(plr.Name.."Time")
if oldval then
oldval:Destroy()
end
end)
timeEvent.OnServerInvoke = function(player)
timeVal = folder:FindFirstChild(tostring(player).."Time")
if timeVal then
if timeVal:IsA("NumberValue") then
return timeVal.Value
else return 0
end
else return 0
end
end

3 comments
Because it's in ROBLOX studio. test in a actual game
oh wow I'm stupid
Write solved in front of the question or delete it.