Hello! Today I was trying to use this DataStore for my Tools the problem I am having is I can’t reset the Data for tools when I am testing the game. I have tried Re Writing the code a bunch of different ways AND I have looked at a bunch of tutorials and other forums but I can’t seem to get it to work the way I would like, I have tried adding a Table and separate Data for it listing all the tools in the folder but it just won’t work and it keeps saving the Data even if I delete the script. If anyone could help me out I would really appreciate it Thank You!
The script I have now
local name = "PurchasedSwords"
game.Players.PlayerAdded:connect(function(player)
local DataStore = game:GetService("DataStoreService")
local Starter = Instance.new("Folder",player)
Starter.Name = name
for i,v in pairs(game.ServerStorage.Swords:GetChildren()) do
local Main = DataStore:GetDataStore(name .." ".. v.SwordName.Value.."Noob")
local Backup = DataStore:GetDataStore(name .." ".. v.SwordName.Value.."Noob1")
local x = Instance.new("BoolValue",Starter)
x.Name = v.SwordName.Value
if Main:GetAsync(player.UserId) == Main:GetAsync(player.UserId) then
x.Value = Main:GetAsync(player.UserId) or v.DefaultValue.Value
else
x.Value = Main:GetAsync(player.UserId) or v.DefaultValue.Value
end
end
end)
game.Players.PlayerRemoving:Connect(function(player)
for i,v in pairs(game.ServerStorage.Swords:GetChildren()) do
print("Getting")
local DataStore = game:GetService("DataStoreService")
local Main = DataStore:GetDataStore(name .." ".. v.SwordName.Value.."Noob")
local Backup = DataStore:GetDataStore(name .." ".. v.SwordName.Value.."Noob1")
Main:SetAsync(player.UserId, player[name][v.SwordName.Value].Value)
Backup:SetAsync(player.UserId, player[name][v.SwordName.Value].Value)
print("Saved")
end
end)