Well I have a datastore setup the issue is when I print out the health value it comes out as 50 not 100 and the saves isn't working when I changed the value. So like if I join in the game again when I changed the value it will come out as 50 so that means if it came out as 0 it should of been 100 not 50... Code:
--[[
Hunger,Thirst,Health
--]]
wait()
local Data = game:GetService("DataStoreService")
local HungerValue = Data:GetDataStore("8432345EKF")
local ThirstValue = Data:GetDataStore("83924355KJ")
local HealthValue = Data:GetDataStore("38533456KD")
name = "PurelyMystic"
pls = game.Players:GetUserIdFromNameAsync(name)
print(HealthValue:GetAsync(pls))
game.Players.PlayerAdded:connect(function(plr)
print("Joined")
local folder = Instance.new("Folder", plr)
local hunger = Instance.new("IntValue", folder)
local thirst = Instance.new("IntValue", folder)
local health = Instance.new("IntValue", folder)
folder.Name = "Stats"
hunger.Name = "Hunger"
thirst.Name = "Thirst"
health.Name = "Health"
hunger.Value = HungerValue:GetAsync(plr.userId) or 100
thirst.Value = ThirstValue:GetAsync(plr.userId) or 100
health.Value = HealthValue:GetAsync(plr.userId) or 100
end)
game.Players.PlayerRemoving:connect(function(plr)
local stat = plr.Stats
HungerValue:SetAsync(plr.userId, stat.Hunger.Value)
ThirstValue:SetAsync(plr.userId, stat.Thirst.Value)
HealthValue:SetAsync(plr.userId, stat.Health.Value)
end)

1 comment
Pls put your cod is a code block