im trying to make it so where when you buy a shirt or somethingf i made datas to where if your wearing the shirt and if u have the shirt like HasShirtValue -- means wearing shirt and BoughtShirtValue-- means bought shirt
i want it to be like if u bought the shirt it adds into your inventory table but how do i do that?
Inventory ={}
Player = game:GetService('Players').LocalPlayer
game.Players.PlayerAdded:connect(function(NPlayer)
local vs = script:WaitForChild("Data"):clone()
vs.Parent = NPlayer
NPlayer:LoadCharacter()
local Stats = vs:GetChildren()
local S1 = {}
for i=1,#Stats do
local n = Stats[i].Name
S1[n] = Stats[i].Value
end
if NPlayer.Name ~= "Player" then
local DataStore = game:GetService("DataStoreService"):GetDataStore("Version 0.1",NPlayer.userId)
if DataStore:GetAsync("Stats") == nil then
DataStore:SetAsync("Stats", S1)
end
S1 = DataStore:GetAsync("Stats")
end
local vv = vs:GetChildren()
for i=1,#vv do
local n = vv[i].Name
if S1[n] ~= nil then
vv[i].Value = S1[n]
end
end
end)
game.Players.PlayerRemoving:connect(function(p)
local DataStore = game:GetService("DataStoreService"):GetDataStore("Version 0.1",p.userId)
local stats = p:FindFirstChild("Data"):GetChildren()
local s1 = {}
for i=1,#stats do
local n = stats[i].Name
s1[n] = stats[i].Value
end
DataStore:SetAsync("Stats",s1)
end)
------BUYING THIS IIS JN A LOCAL SCRIPT
Buy.MouseButton1Down:connect(function()
print("Buying Item")
if Bod.Value =="Hats" then
if E.Value == "Black Beanie" and SPINS >= 20 and Data.BoughtBlackBeanie.Value == false then
SPINS = SPINS -20
Data.BoughtBlackBeanie.Value = true
Data.HasBlackBeanie.Value = true
else
Buy.Text = "nil"
wait(1)
Buy.Text = "Buy"
end
