Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local buttons = script.Parent.Buttons
- local shopping = script.Parent.Shopping
- local storage = {}
- local DSS = game:GetService("DataStoreService")
- local Bank = DSS:GetDataStore("Money")
- local function hideButton(button)
- button.CanTouch = false
- button.Transparency = 1
- button.Billboard.Enabled = false
- end
- local function showButton(button)
- button.CanTouch = true
- button.Transparency = 0
- button.Billboard.Enabled = true
- end
- local function newButton(button)
- local purchase
- local name = button.Name
- if shopping:FindFirstChild(name) then
- purchase = shopping[name]
- storage[name] = purchase:Clone()
- purchase:Destroy()
- else
- warn("Missing a purchase : " .. name)
- end
- if not (name == "1") then
- hideButton(button)
- end
- button.Touched:Connect(function(hit)
- local player = game.Players:FindFirstChild(hit.Parent.Name)
- if player then
- local purchase = storage[name]
- if purchase then
- purchase.Parent = shopping
- end
- for i, element in pairs(button:GetChildren()) do
- if element.Name == "Next" then
- local buttonToShow=buttons:FindFirstChild(element.Value)
- if buttonToShow then
- showButton(buttonToShow)
- else
- warn("Missing button: " .. element.Value)
- end
- end
- end
- button:Destroy()
- end
- end)
- end
- game.Players.PlayerAdded:Connect(function(player)
- local money = Bank:GetAsync(player.UserId) or 0
- local billboardOnServer = Instance.new("Folder", game.ServerStorage)
- billboardOnServer.Name = player.Name
- local moneyOnServer = Instance.new("NumberValue", billboardOnServer)
- moneyOnServer.Name = "Money"
- moneyOnServer.Value = money
- local billboardLocally = Instance.new("Folder", player)
- billboardLocally.Name = "leaderstats"
- local moneyLocally = Instance.new("NumberValue", billboardLocally)
- moneyLocally.Name = "Money"
- moneyLocally.Value = money
- for i, button in pairs(buttons:GetChildren()) do
- newButton(button)
- end
- player:LoadCharacter()
- moneyOnServer.Changed:Connect(function(number)
- moneyLocally.Value = number
- end)
- while true do
- Bank:SetAsync(player.UserId, moneyOnServer.Value)
- print("Money saved!")
- wait(10)
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement