Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do you place data persistence on a GUI?

Asked by 10 years ago

I already have the data persistence for points, but I don't know how to use data persistence yet. I am trying to make a GUI shop wherein when you buy something, it saves.

I am a beginner scripter, so any help is greatly appreciated :D

1
I would recommend Data Stores fahmisack123 385 — 10y

1 answer

Log in to vote
1
Answered by 10 years ago
game.Players.PlayerAdded:connect(function(player)
    local itemBought = Instance.new("IntValue",player)
    itemBought.Value = false
    itemBought.Name = "ItemBought"
    player:WaitForDataReady()
    player.ItemBought.Value = player:LoadNumber("ItemBought",player.ItemBought.Value)--Loads 'ItemBought's' Value
end

game.Players.PlayerRemoving:connect(function(player)
    player:WaitForDataReady()
    player:SaveNumber("ItemBought",player.ItemBought.Value) -- Saves 'ItemBought's' Value
end


0
Thank you so much! :D This really helped DEATHmaster129 5 — 10y
0
Anytime. ObscureEntity 294 — 10y
Ad

Answer this question