This saving and loading script won't work, can anyone tell why?
plrs = Instance.new("BoolValue", game.Lighting) plrs.Name = "plrs" owner = "Mr1Vgy" game.Players.PlayerAdded:connect(function(plr) local p = Instance.new("BoolValue", game.Lighting.plrs) p.Name = plr.Name local l = Instance.new("IntValue", plr) l.Name = "leaderstats" local wins = Instance.new("NumberValue", l) wins.Name = "Wins" local cash = Instance.new("NumberValue", l) cash.Name = "Cash" local items = Instance.new("Model", plr) items.Name = "items" local e = Instance.new("Model", plr) e.Name = "equiped" local bloxy = Instance.new("StringValue", plr.equiped) bloxy.Name = "Bloxy Cola" plr:WaitForDataReady() plr.leaderstats.Wins.Value = plr:LoadNumber("Wins", plr.leaderstats.Wins.Value) plr.leaderstats.Cash.Value = plr:LoadNumber("Cash", plr.leaderstats.Cash.Value) items = plr:LoadInstance("items") print('loaded stats for '..plr.Name) plr.Chatted:connect(function(msg) if plr.Name == owner and string.lower(msg) == "plus 500" then plr.leaderstats.Cash.Value = plr.leaderstats.Cash.Value + 500 end end) end) game.Players.PlayerRemoving:connect(function(plr) if game.Lighting.plrs:FindFirstChild(plr.Name)then game.Lighting.plrs[plr.Name]:remove() local find = game.Lighting:FindFirstChild("fighting") if find then if find:FindFirstChild(plr.Name)then find[plr.Name]:remove() find.Value = find.Value - 1 end end end plr:SaveNumber("Wins", plr.leaderstats.Wins.Value) plr:SaveNumber("Cash", plr.leaderstats.Cash.Value) plr:SaveInstance("items", plr.items) print('stats saved for '..plr.Name) end)
wait(.1) -- Erm, use it in-game and not in-studio to test. plrs = Instance.new("BoolValue", game.Lighting) plrs.Name = "plrs" wait(.1) owner = "Mr1Vgy" -- ... game.Players.PlayerAdded:connect(function(plr) local p = Instance.new("BoolValue", game.Lighting.plrs) p.Name = plr.Name local l = Instance.new("IntValue", plr) l.Name = "leaderstats" local wins = Instance.new("NumberValue", l) wins.Name = "Wins" local cash = Instance.new("NumberValue", l) cash.Name = "Cash" local e = Instance.new("Model", plr) e.Name = "equiped" local bloxy = Instance.new("StringValue", plr.equiped) bloxy.Name = "Bloxy Cola" plr:WaitForDataReady() plr.leaderstats.Wins.Value = plr:LoadNumber("Wins", plr.leaderstats.Wins.Value) plr.leaderstats.Cash.Value = plr:LoadNumber("Cash", plr.leaderstats.Cash.Value) local items = plr:LoadInstance("items") -- Don't overwrite instances, their not variables :3 items.Parent=plr items.Name="items" print('loaded stats for '..plr.Name) plr.Chatted:connect(function(msg) if plr.Name == owner and string.lower(msg) == "plus 500" then plr.leaderstats.Cash.Value = plr.leaderstats.Cash.Value + 500 end end) end) game.Players.PlayerRemoving:connect(function(plr) if game.Lighting.plrs:FindFirstChild(plr.Name) then game.Lighting.plrs:findFirstChild(plr.Name):remove() -- don't use models like tables, their an instance local find = game.Lighting:FindFirstChild("fighting") if find then if find:FindFirstChild(plr.Name)then find:findFirstChild(plr.Name):remove() find.Value = find.Value - 1 end end end plr:SaveNumber("Wins", plr.leaderstats.Wins.Value) plr:SaveNumber("Cash", plr.leaderstats.Cash.Value) plr:SaveInstance("items", plr.items) print('stats saved for '..plr.Name) end)
Please tell output and what doesn't load...
Hope this helps! If not tell output ~marcoantoniosantos3