Hi, so I'm making a game and it has a leaderstats script, but the problem is, the leaderstats won't save. It's a normal script in workspace and it's a place inside of a game, if you know what I mean. Script:

CashStore = game:GetService("DataStoreService"):GetDataStore("DataStore")

function PlayerEntered(player)
	repeat wait() until player.Character
	
	local stats = Instance.new("IntValue")
	stats.Parent = player
	stats.Name = "leaderstats"
	
	local Girl = Instance.new("IntValue")
	Girl.Parent = stats
	Girl.Name = "Girl"
	
	if CashStore:GetAsync("Points_"..player.Name) ~= nil then
		Girl.Value = CashStore:GetAsync("Points_"..player.Name)
	else
		Girl.Value = 0
	end

local Boy = Instance.new("IntValue")
	Boy.Parent = stats
	Boy.Name = "Boy"
	
	if CashStore:GetAsync("Points_"..player.Name) ~= nil then
		Boy.Value = CashStore:GetAsync("Points_"..player.Name)
	else
		Boy.Value = 0
	end

local Hair1 = Instance.new("IntValue")
	Hair1.Parent = stats
	Hair1.Name = "Hair1"
	
	if CashStore:GetAsync("Points_"..player.Name) ~= nil then
		Hair1.Value = CashStore:GetAsync("Points_"..player.Name)
	else
		Hair1.Value = 0
	end
	
	Girl.Changed:connect(function(Val)
		CashStore:SetAsync("Points_"..player.Name, Val)
	end)
Boy.Changed:connect(function(Val)
		CashStore:SetAsync("Points_"..player.Name, Val)
	end)
Hair1.Changed:connect(function(Val)
		CashStore:SetAsync("Points_"..player.Name, Val)
	end)
end

game.Players.PlayerAdded:connect(PlayerEntered)

Thank you!

4 comments

0

put it into ServerScriptService

0

@Dan_PanMan, thanks for replying, but it didn't work...

0

Did you enable http request?

0

@Jackpotpokeadot1, Hi, thanks for replying. Yes, I did do that, but it's still not saving...