so i made a leaderboard and stats and i need them both to save this is the script i have so far:

local DataStore = game:GetService("DataStoreService"):GetDataStore("GodSimulator")

game.Players.PlayerAdded:connect(function(plr)
	local key = "key-" ..plr.userId
local leaderstats = Instance.new("Folder",plr)
leaderstats.Name = "leaderstats"
local Holyness = Instance.new("IntValue",leaderstats)
Holyness.Name = "Holyness"
local Level = Instance.new("IntValue",leaderstats)
Level.Name = "Level"
local Stats = Instance.new("Folder",plr)
Stats.Name = "Stats"
local Gain = Instance.new("IntValue",Stats)
Gain.Name = "Gain"
local Wait = Instance.new("IntValue",Stats)
Wait.Name = "Wait"
local Size = Instance.new("IntValue",Stats)
Size.Name = "Size"
	local save = DataStore:GetAsync(key)
	if save then
		Holyness.Value = save[1]
		Level.Value = save[2]
		Gain.Value = save[3]
		Wait.Value = save[4]		
		Size.Value = save[5]
	else
		local load = {Holyness.Value,Level.Value,Gain.Value,Wait.Value,Size.Value}
		DataStore:SetAsync(key,load)
	end
	local H = game.Workspace:WaitForChild(plr.Name).Humanoid
	H.HeadScale.Value = 0.5
	H.BodyHeightScale.Value = 0.5
	H.BodyWidthScale.Value = 0.5
	H.BodyDepthScale.Value = 0.5
	H.WalkSpeed = 8
	H.JumpPower = 12.5
	H.MaxHealth = 50
	H.Health = 50
	if Gain.Value == 0 and Wait.Value == 0 and Size.Value == 0 then
		Gain.Value = 1
		Wait.Value = 1.5
		Size.Value = 1
	end
end)

game.Players.PlayerRemoving:connect(function(plr)
	local key = "key-"..plr.userId
	local load = {plr.leaderstats:FindFirstChild("Holyness").Value,plr.leaderstats:FindFirstChild("Level").Value,plr.Stats:FindFirstChild("Gain").Value,
		plr.Stats:FindFirstChild("Wait").Value,plr.Stats:FindFirstChild("Size").Value}
	DataStore:SetAsync(key,load)
end)

Can anyone fix the script so that it will work cause right now it doesn't Thanks!1

3 comments

0

no because we don't know what your doing

0

It's probably just a copy of weight lifting simulator 2... So many leaks and copied versions slightly modified.