Basically, I wanted to make a coin in replicatedstorage spawn at a specific place in-game for 10 minutes only at 6 PM EST everyday, and I wanted to make it so that only 1 player can get it, so once it spawns only one player can touch the coin and the player that touches it first only gets a specific badge, so when that someone gets it, it despawns and only spawns again at 6 PM EST the other day. How can I make this?
1 Like
You can use os.time() to get the real time.
2 Likes
Use a DateTime
object.
local now = DateTime.now()
local components = now:ToUniversalTime()
print(components.Hour == 18) -- This is in UTC, apply offset to account for timezone
2 Likes
I still don’t understand how to do this as I barely have any scripting knowledge, but this is what I got so far (I’m not sure how to implement the Date/Time stuff)
ServerScript under ServerScriptService (Main script):
local rs = game:GetService("ReplicatedStorage")
local coin = rs:WaitForChild("WhiteCoin")
local remote = rs.Remotes.AwardWhiteCoinBadge
local pos = game.Workspace:WaitForChild("WhiteCoinTP")
coin.Parent = workspace
coin.Touched:Connect(function(part)
if part.Parent:FindFirstChild("Humanoid") then
remote:FireServer()
end
end)
task.wait(10)
coin.Parent = rs
ServerScript in ServerScriptService (Handles the badge award, via using RemoveEvent in ReplicatedStorage):
local whiteCoinRemote = game.ReplicatedStorage.Remotes.AwardWhiteCoinBadge
whiteCoinRemote.OnServerEvent:Connect(function(player)
game.BadgeService:AwardBadge(player.UserId,1088875429822925)
end)
I seem to have the same issue. Still cannot find out! Help us out, please.
1 Like