i am currently making a permadeath kind of game, and im implementing an “in danger” feature to prevent people from leaving the game and recieving no punishment, but for some reason even if the “InDanger” value is true it will return in false no matter what i do, anyone has an idea on why this happens, and could give me a fix?
Edit: The datastore itself has started breaking and no longer wants to save values like “speed”
Edit #2: i managed to find a way to fix the other values refusing to save, i havent been able to fix the “InCombat” Value yet
Code
local datastore = game:GetService("DataStoreService"):GetDataStore("DusunV2#0.1")
game.Players.PlayerAdded:Connect(function(player)
--<<Folder>>
local StatsFolder = Instance.new("Folder")
StatsFolder.Name = "Data"
StatsFolder.Parent = player
warn("Folder has been set up")
--<<Values>>
local Charisma = Instance.new("IntValue")
Charisma.Name = "Charisma"
Charisma.Parent = StatsFolder
local Strength = Instance.new("IntValue")
Strength.Name = "Strength"
Strength.Parent = StatsFolder
local Speed = Instance.new("IntValue")
Speed.Name = "Speed"
Speed.Parent = StatsFolder
local Stamina = Instance.new("IntValue")
Stamina.Name = "Stamina"
Stamina.Parent = StatsFolder
local InCombat = Instance.new("BoolValue")
InCombat.Name = "InCombat"
InCombat.Parent = StatsFolder
warn("Values have been set up")
local key = "user-" .. player.userId
local storeditems = datastore:GetAsync(key)
if storeditems then
Strength.Value = storeditems[1]
Speed.Value = storeditems[2]
InCombat.Value = storeditems[3]
warn(player.Name.."'s data has loaded... ID"..player.userId)
wait(1)
if InCombat.Value == true then
warn(player.Name.." HAS BEEN FOUND IN COMBAT... ID"..player.UserId)
InCombat.Value = false
end
else
local items = {Strength.Value, Speed.Value, InCombat.Value}
datastore:SetAsync(key, items)
warn(player.Name.." has no data... ID"..player.UserId)
end
end)
game.Players.PlayerRemoving:connect(function(player)
local items = {player.Data.Strength.Value, player.Data.Speed.Value}
local key = "user-" .. player.userId
warn(player.Name.."'s data has been saved... ID"..player.UserId)
datastore:SetAsync(key, items)
end)