Save stats not working

can someone help me i Trying to create a Stats script no errors only problem is t wont save somehow

Script:

local DataStoreService = game:GetService("DataStoreService"):GetDataStore("saveData")
game.Players.PlayerAdded:Connect(function(player)
	wait(0.1)
	local player_Key = "Test3"..player.UserId
	
	--Currency
	local yinV = player.yin
	--stats
	local FistStrengthV = player.FistStrength
	local BodyToughnesV = player.BodyToughnes
	local MovementSpeedV = player.MovementSpeed
	local JumpForceV = player.JumpForce
	local PsychicPowerV = player.PsychicPower
	
	--Multiplayers
	local FSMultiV = player.FSMulti
	local BTMultiV = player.BTMulti
	local MSMultiV = player.MSMulti
	local JFMultiV = player.JFMulti
	local PPMultiV = player.PPMulti
	
	local getSaved = DataStoreService:GetAsync(player_Key)
	if getSaved then
		FistStrengthV.Value = getSaved[1]
		yinV.Value = getSaved[2]
		BodyToughnesV.Value = getSaved[3]
		MovementSpeedV.Value = getSaved[4]
	    JumpForceV.Value = getSaved[5]
		PsychicPowerV.Value = getSaved[6]
	else
		local Values = {FistStrengthV.Value, FistStrengthV.Value, yinV.Value, BodyToughnesV.Value, MovementSpeedV.Value, JumpForceV.Value, PsychicPowerV.Value, FSMultiV.Value, BTMultiV.Value,MSMultiV.Value, JFMultiV.Value, PPMultiV.Value}
		DataStoreService:GetAsync(player_Key, Values)
	end
end)



game.Players.PlayerRemoving:Connect(function(player)
	DataStoreService:GetAsync("Test3"..player.UserId,{player.FistStrength.Value, player.yin.Value, player.BodyToughnes.Value, player.MovementSpeed.Value, player.JumpForce.Value, player.PsychicPower.Value, player.FSMulti.Value, player.BTMulti.Value, player.MSMulti.Value, player.JFMulti.Value, player.PPMulti.Value})
end)
1 Like

Instead of GetAsync you need to use DataStoreService:SetAsync. Consider also using DataStoreService:UpdateAsync.

1 Like

Wait how i gone do that ?

do i need to change Getasync to setasync and then?

1 Like

for the 2nd last line u need to change it

1 Like

Oh Completely didint see that Thanks for the help both of you

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.