Hello! How do I make a tycoon save system using Gamer m8’s tutorial?
Others:
Buttons
Main Items:
I hope you can help, thx
The main script:
local TycoonModel = script.Parent.Parent
local items = {}
local BoughtItems = TycoonModel:FindFirstChild("BoughtItems")
local Buttons = TycoonModel:FindFirstChild("Buttons")
local DropperParts = TycoonModel:FindFirstChild("DropperParts")
local MainItems = TycoonModel:FindFirstChild("MainItems")
local Scripts = TycoonModel:FindFirstChild("Scripts")
local Values = TycoonModel:FindFirstChild("Values")
--- Owner Functions ---
MainItems.OwnerDoor.MainDoor.Touched:Connect(function(Hit)
if Hit.Parent:FindFirstChild("Humanoid") and Values.OwnerValue.Value == nil then
local Players = game.Players:GetPlayerFromCharacter(Hit.Parent)
Values.OwnerValue.Value = Players
MainItems.OwnerDoor.MainDoor.SurfaceGui.TextLabel.Text = tostring(Values.OwnerValue.Value).. " Tycoon"
end
end)
--- Buying Functions ---
for i,v in pairs(Buttons:GetChildren()) do
local NewItem = BoughtItems:FindFirstChild(v.Item.Value)
if NewItem ~= nil then
items[NewItem.Name] = NewItem:Clone()
NewItem:Destroy()
else
v.ButtonPart.Transparency = 1
v.ButtonPart.CanCollide = false
v.ButtonPart.BillboardGui.Frame.Visible = false
end
if v:FindFirstChild("Dependency") then
coroutine.resume(coroutine.create(function()
v.ButtonPart.Transparency = 1
v.ButtonPart.CanCollide = false
v.ButtonPart.BillboardGui.Frame.Visible = false
if BoughtItems:WaitForChild(v.Dependency.Value, 100000) then
v.ButtonPart.Transparency = 0
v.ButtonPart.CanCollide = true
v.ButtonPart.BillboardGui.Frame.Visible = true
end
end))
end
v.ButtonPart.Touched:Connect(function(Hit)
if Hit.Parent:FindFirstChild("Humanoid") then
local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
if Values.OwnerValue.Value == Player then
if v.ButtonPart.CanCollide == true and v.ButtonPart.Transparency == 0 then
if Player:WaitForChild("leaderstats").Cash.Value >= v.Price.Value then
Player.leaderstats.Cash.Value -= v.Price.Value
items[v.Item.Value].Parent = BoughtItems
v:Destroy()
end
end
end
end
end)
end
---Cash Function---
local Debounce = false
MainItems.CashButton.ButtonPart.Touched:Connect(function(Hit)
if Hit.Parent:FindFirstChild("Humanoid") then
local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
if Values.OwnerValue.Value == Player then
if Debounce == false then
Debounce = true
Player:WaitForChild("leaderstats").Cash.Value += Values.CashValue.Value
wait()
Values.CashValue.Value = 0
wait(1)
Debounce = false
end
end
end
end)
while wait() do
MainItems.CashButton.ScreenPart.SurfaceGui.TextLabel.Text = Values.CashValue.Value
end