im trying to make it so when you have touched the part, it will add stats once. When you leave the game and join back and touch the part, it will not add the stats because you already touched the part before. Basically like a datastore but with touching a part and not number values
--//ServerScript wait(2) local sell = script.Parent local debounce = false local tool = game.ReplicatedStorage.Present local toFire = script.Parent.Client local ds = game:GetService("DataStoreService") local dss = ds:GetDataStore("NotMyRealDataStoreNameBtw") game.Players.PlayerAdded:Connect(function(plr) local key = "upgrade-"..plr.UserId local folder = Instance.new("Folder",plr) folder.Name = "Upgrades" local save = dss:GetAsync(key) if save then for i = 1,#save do local temp = Instance.new("BoolValue",folder) temp.Name = save[1] end end end) sell.Touched:Connect(function(hit) if not debounce then debounce = true if hit.Parent:FindFirstChild("Humanoid")then local plr = workspace[hit.Parent.Name] local player = game.Players:GetPlayerFromCharacter(plr) local key = "upgrade-"..player.UserId local bool = Instance.new("BoolValue",player.Upgrades) bool.Name = "Upgrade" bool.Value = true local activated = {} local Capacity = game.ReplicatedStorage.Capacity local upgrades = player:WaitForChild("Upgrades") local money = player.leaderstats.Money if not upgrades:FindFirstChild("Upgrade")and money.Value >= 2000 then local reward = 25 Capacity.Value = Capacity.Value + reward for i,v in pairs(player.Upgrades:GetChildren())do if v:isA("BoolValue")then table.insert(activated, v.Name) dss:SetAsync(key,activated) print("Upgrade Success") else print("Upgrade already purchased") Capacity.Value = Capacity.Value + 0 wait(1) debounce = false end end end end end end)