local Players = Game:GetService("Players")
print("STARTING")
Players.PlayerAdded:connect(function(plr)
local health = plr:WaitForChild("leaderstats"):WaitForChild("Health")
plr.CharacterAdded:connect(function(char)
if health.Value < 100 then
health.Value = 100
end
char:WaitForChild("Humanoid").MaxHealth = health.Value
print("Provided health on join")
end)
health.Changed:connect(function(h)
if plr.Character then
plr.Character:FindFirstChild("Humanoid").MaxHealth = h
print("Provided health on respawn")
end
end)
end)
This is currently placed within the ServerScriptStorage. It's currently not doing anything. Is there anything wrong with it? (The output doesn't say anything, not even the prints.)
function DataHandler(p,o,key)
local types = {
IntValue = "Number";
NumberValue = "Number";
ObjectValue = "Instance";
BoolValue = "Boolean";
StringValue="String";
}
local t = types[o.ClassName]
if (not t) then return end
key = (type(key) == "string" and key or o.Name)
key = (#key > 0 and key or key.Name == o.Name and o.ClassName or o.Name)
if (not p.DataReady) then
p:WaitForDataReady()
end
local Save,Load = p[("Save%s"):format(t)],p[("Load%s"):format(t)]
o.Value = Load(p,key)
local lastV = o.Value
o.Changed:connect(function(v)
lastV = v
Delay(1,function()
if (lastV ~= v) then return end
Save(p,key,v)
end)
end)
end
game.Players.PlayerAdded:connect(function(player)
local l = Instance.new("IntValue",player)
l.Name = "leaderstats"
local kill = Instance.new("IntValue",l)
kill.Name = "KOs"
DataHandler(player,kill,"Thekills")
local death = Instance.new("IntValue",l)
death.Name = "Wipeouts"
DataHandler(player,death,"Thedeaths")
local mh = Instance.new("IntValue",l)
mh.Name = "Health"
DataHandler(player,mh,"MaxHealths")
end)

3 comments
The thing is, I have a script that provides the IntValue's already. And it runs off of datasave. I want a different script to edit the IntValue's.
Seems a little in-efficient, and the timing may get messed up. But if you can figure a way to do it.
Do you just want me to upload the datasave script so you can edit it?