There is a lot of data I need to save a lot of data in my game. Right now when a player joins the game the data is created in Lighting. Is data able to save here?
I'm trying to save it but it doesn't work.
These are the parts of my code that matter:
local DataStoreService = game:GetService("DataStoreService")
local DS1 = DataStoreService:GetDataStore("SavePoints")
-- Player Added --
game.Players.PlayerAdded:connect(function(plr)
local Points = Instance.new("NumberValue", Leaderstats)
Points.Name = ("Points")
local GetData = DS1:GetAsync(plr.UserId)
if GetData then
Points.Value = GetData
DS1:SetAsync(plr.UserId, Points.Value)
else
Points.Value = 0
DS1:SetAsync(plr.UserId, Points.Value)
end
end)
-- Player Removed --
game.Players.PlayerRemoving:Connect(function(plr)
DS1:SetAsync(plr.UserId, game.Lighting:FindFirstChild(plr.Name).Points.Value)
end)
Thank you to anyone who helps.

2 comments
I'm not quite familiar enough with DS1 to fix your error so I apologize for that, but if it's a numbVal, it's a numbVal. It should still read whether it's parent is lighting or not. A better question would be why is your values in lighting? Why not serverStorage?
Thank you for your input Bees. DS1 would hold the value of the points once it is saved, so it would be a number value. As to why I didn't use server storage, this is a project I started a long time ago and if I had known more I probably would have put it in Lighting. I'll try moving everything to sever storage and see if that works for me.