Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

help, it wont work, it doesnt save my progress, what do i do?

local script:

script.Parent.MouseButton1Click:Connect(function()
game.ReplicatedStorage.UpdateData:FireServer()
end)

server script:

local DStoreService = game:GetService("DataStoreService")
local CashStore = DStoreService:GetDataStore("Cash")

game.ReplicatedStorage.UpdateData.OnServerEvent:Connect(function(plr)
	
		local MaxHealth = game.Workspace:WaitForChild("player.Name"):WaitForChild("Humanoid").MaxHealth
		local CashValue = plr:WaitForChild("leaderstats"):WaitForChild("Cash").Value
		CashStore:SetAsync("plr_"..plr.UserId, CashValue, MaxHealth)

end)
game.Players.PlayerRemoving:Connect(function(plr)
	local MaxHealth = game.Workspace:WaitForChild("player.Name"):WaitForChild("Humanoid").MaxHealth
	local CashValue = plr:WaitForChild("leaderstats"):WaitForChild("Cash").Value
	CashStore:GetAsync("plr_"..plr.UserId, CashValue, MaxHealth)
end)

it wont save my progress

4 comments

0

I dont think you can 3 parameters inside the line 14 I think you can only put 2

0

put*

0

ok

0

ok

2 answers

Try using the actual game and not Roblox Studio or in Game Settings on Security and turn on Studio Access to API Services

1 comment

0

did all of that

Change the MaxHealth variable to this

local Character = plr.Character or plr.CharacterAdded:Wait()
local MaxHealth = Character:FindFirstChildWhichIsA("Humanoid").MaxHealth

2 comments

0

Why did my post get downvoted?

0

You're not using setasync and getasync correctly + you can't save 2 stats like that

This discussion is preserved as it was. New answers, comments, and votes are closed.