Hello. So, I‘ll explain, how to make an AutoCollect “Button/Gamepass” for @Zed_Gaming’s Tycoon Kit (also works with @TwinPlayzDev 's Tycoon Kit)
First: we need to open the Model’s (TycoonKit → Tycoons → NameOfTycoon )
Now we have to script. Insert in every Tycoon a script.
I am trying to explain it well, please don’t judge me
local cooldown = 1
local Owner = script.Parent.Owner
Here we created two local variables! The cooldown is for the time you get Cash (here one second). The second one is the Owner.
while task.wait(cooldown) do
end)
Here, we created a loop. This will basically make this: wait cooldown, do code, wait cooldown and so on.
while task.wait(cooldown) do
if Owner.Value ~= nil and script.Parent.PurchasedObjects:FindFirstChild("AutoCollect") then
end
end)
We checked here, if the Owner exists and if he bought our Button, that we’ll create later.
while task.wait(cooldown) do
if Owner.Value ~= nil and script.Parent.PurchasedObjects:FindFirstChild("AutoCollect") then
if game.Players:FindFirstChild(tostring(Owner.Value)) then
local Stats = game.ServerStorage.PlayerMoney:FindFirstChild(game.Players:FindFirstChild(tostring(Owner.Value)))
if Stats ~= nil then
end
end
end
end)
Here we check another time if the player really exists, we created the “Stats” Variable and checked if the “Stats” Variable isn’t nil.
Stats.Value = Stats.Value += script.Parent.CurrencyToCollect.Value
script.Parent.CurrencyToCollect.Value = 0
So past this under “if Stats ~= nil then”.
The entire code
while task.wait(cooldown) do
if Owner.Value ~= nil and script.Parent.PurchasedObjects:FindFirstChild("AutoCollect") then
if game.Players:FindFirstChild(tostring(Owner.Value)) then
local Stats = game.ServerStorage.PlayerMoney:FindFirstChild(game.Players:FindFirstChild(tostring(Owner.Value)))
if Stats ~= nil then
Stats.Value = Stats.Value += script.Parent.CurrencyToCollect.Value
script.Parent.CurrencyToCollect.Value = 0
end
else
print("No plr Found") -- Just ignore/delete that
end
end
end)
Now make a Button in “Buttons” with Object=AutoCollect (best: make a int-Value called “Gamepass” with your Gamepass Id). Then Make an Model (best is nothing inside) in “Purchases” that you call “AutoCollect”.
If that was too much for you, you can get the Model here.