Heya!
Im trying to create a system where you gain a value. However. Im using a module script and i dont know how to add time
Module
local MerchantHandler = {}
local Player = game:GetService("Players").LocalPlayer
local LeaderstatsFolder = Player:WaitForChild("leaderstats")
local BoostsFolder = Player:WaitForChild("Boosts")
MerchantHandler.PotionPurchaseCooldown = 3600 -- (3600 = 1 Hour), (86400 = 1 Day)
MerchantHandler.Items = {
["Potion1"] = {Potion = BoostsFolder["Gem Potion"].Value, Time = 30, Image = "rbxassetid://15434984615", Title = "Gem Potion", MaxPurchase = 1, Purchased = 0, Price = 12, Currency = LeaderstatsFolder:WaitForChild("Taps")},
["Potion2"] = {Potion = BoostsFolder["Super Lucky"].Value, Time = 60, Image = "rbxassetid://15434984615", Title = "Super Luck Potion", MaxPurchase = 2, Purchased = 0, Price = 24, Currency = LeaderstatsFolder:WaitForChild("Taps")},
["Potion3"] = {Potion = BoostsFolder["Extra Lucky"].Value, Time = 90, Image = "rbxassetid://15434984615", Title = "Luck Potion", MaxPurchase = 3, Purchased = 0, Price = 36, Currency = LeaderstatsFolder:WaitForChild("Taps")},
}
function MerchantHandler.CreatePotionPurchaseFrame(name)
local Template = script.Parent:WaitForChild("Potion1"):Clone()
local gui = Player.PlayerGui:WaitForChild("Main"):WaitForChild("PotionMerchant")
Template.Name = MerchantHandler.Items[name].Title
Template.Icon.Image = MerchantHandler.Items[name].Image
Template.PotionName.Text = MerchantHandler.Items[name].Title
Template.Purchased.Text = MerchantHandler.Items[name].Purchased.."/"..MerchantHandler.Items[name].MaxPurchase
Template.PriceLabel.Text = MerchantHandler.Items[name].Price.." "..MerchantHandler.Items[name].Currency.Name
Template.Parent = gui:WaitForChild("Main"):WaitForChild("Container")
Template.BuyButton.Button.MouseButton1Click:Connect(function()
if MerchantHandler.Items[name].Currency.Value >= MerchantHandler.Items[name].Price then
script.Parent.PotionPurchased:InvokeClient(Player)
end
end)
end
return MerchantHandler
Server Script
local repStorage = game:GetService("ReplicatedStorage")
local PurchaseEvent = repStorage:WaitForChild("Merchant").PotionPurchased
local PurchaseInfo = require(repStorage:WaitForChild("Merchant").MerchantHandler)
PurchaseEvent.OnServerInvoke = function(player, PotionPurchased)
local Potion = player:WaitForChild("Boosts"):FindFirstChild(PotionPurchased)
local info = PurchaseInfo.Items[Potion]
local max = info.MaxPurchased
local purchasecount = info.Purchased
if purchasecount < max then
end
end