Hello, I am making a shop and inventory. With data store, what I want to do is whenever you pressed the buy button, u get an other button visible on ur screen, which shows as ‘equip’. This scripting works. I only don’t know how to add data store, I want whenever I joined the game again, that the button ‘equip’ is still showed, how can I do this?
When the player joins, you can make the script check if the player owns a certain item.
If the player does own the item, add or clone that button into the frame.
1 Like
Can you put it in a script or something?
You don’t need a data store for this you can just use a simple script.
local tool = --Put your tool Name here
local plr = game.Players.LocalPlayer
while true do
if plr.Backpack:FindFirstChild(tool) then
script.Parent.Text = "Equip"
script.Parent.BackgroundColor3 = Color3.new(0.333333, 1, 0.498039)
end
wait(4)
end
Put this in a local script as a child in you equip button
local DataStore = game:GetService("DataStoreService")
local BoughtDS = DataStore:GetDataStore("BoughtDataStore")
local boughtTable = {true, false, false} --true represents first item bought, false represents items not bought
local res = BoughtDS:SetAsync(player.UserId, {boughtTable}) --use this when you want to set data inside the datastore (when a player buys something)
local val = BoughtDS:GetAsync(player.UserId, {boughtTable})
if val[1] then --checks if first item is bought
player:WaitForChild("PlayerGui"):WaitForChild("ScreenGui"):WaitForChild("Frame").Visible = true --something like this to show a UI instance
end