Hello, I’m trying to make a daily rewards system that gives coins to the player if he has joined the group once every 12 hours, but I don’t know how to use os.time, can someone help?
I’m trying to make it so if the player leaves it will still have to wait 12 hours, because now, if a player leaves the game and joins back he can get 2 group rewards without having to wait 12 hours.
Code:
local part = script.Parent.Parent.MeshPart
local GroupID = 10919067
local GroupReward = 500
local Timer = 40000
local CanGet = true
local function onTouch(otherPart)
local humanoid = otherPart.Parent:FindFirstChild("Humanoid")
if humanoid then
local player = game.Players:FindFirstChild(otherPart.Parent.Name)
if player and CanGet then
CanGet = false
if player:IsInGroup(GroupID) then
player.leaderstats.Taps.Value = player.leaderstats.Taps.Value + GroupReward
script.Parent.Part.Thing.Timer.Text = "Come Back in 12 Hours To Claim Your Reward!"
wait(Timer)
CanGet = true
end
end
end
end
part.Touched:Connect(onTouch)