-
What do you want to achieve? Keep it simple and clear!
Hello, so I made a zombie shop, and when the player buy a zombie, I want it to set it a true in the dataStore -
What is the issue? Include screenshots / videos if possible!
Datastore doesnt Update the boolean -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I searched for solutions, changed my code multiple time and still nothing
If you can help me to understand why it doesnt work, I would highly appreciate :D!
This is my DataTable:
function module.SetDataTable()
local UserData = {
Stats = {
["Kills"] = 0,
["Points"] = 0,
},
Quests = {
["no"] = 0,
},
Zombie = {
["Zombie"] = true,
["SpeedZombie"] = false,
["SlowZombie"] = false,
["BigZombie"] = false,
["ChoosenZombie"] = "Zombie",
}
}
return UserData
end
This is my Zombie Shop System
game.ReplicatedStorage.ZombieShop.BuyZombie.OnServerEvent:Connect(function(plr,name)
print(plr,name)
local UserData = DS2("MainKey",plr):Get(Data.SetDataTable())
local StatsData = DS2("Stats",plr)
local ZombieData = DS2("Zombie",plr):Get()
local BuyableFolder = plr:FindFirstChild("AllChecks"):FindFirstChild("BuyableZombiesChecks")
local leaderstats = plr:FindFirstChild("leaderstats")
local price = game.ReplicatedStorage.ZombieShop[name].Price.Value
if ZombieData[name] == true then
warn("Zombie already bought")
else -- Accept the bought
print("testy",BuyableFolder[name])
if leaderstats.Points.Value >= price then
UserData.Stats.Points -= price
ZombieData[name] = true
StatsData:Set(UserData.Stats)
DS2("Zombie",plr):Set(ZombieData[name])
print("Bought!")
else
game.ReplicatedStorage.ZombieShop.BuyZombie:FireClient(plr,false,name)
end
end
end)
And this is the update Value Part:
--All variable are set up
local UserData = DS2("MainKey",player):Get(Data.SetDataTable())
local ZombieData = DS2("Zombie",player)
local function UpdateZombie(Boolean)
print(Boolean)
Zombie.Value = ZombieData:Get(Boolean).Zombie
speedZombie.Value = ZombieData:Get(Boolean).SpeedZombie
slowZombie.Value = ZombieData:Get(Boolean).SlowZombie
bigZombie.Value = ZombieData:Get(Boolean).BigZombie
end
ZombieData:OnUpdate(UpdateZombie)