Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 3 years ago
Edited 3 years ago

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

0
I dont think you can 3 parameters inside the line 14 I think you can only put 2 acediamondn123 147 — 3y
0
put* acediamondn123 147 — 3y
0
ok sonichfan 62 — 3y
0
ok sonichfan 62 — 3y

2 answers

Log in to vote
0
Answered by 3 years ago

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

0
did all of that sonichfan 62 — 3y
Ad
Log in to vote
-1
Answered by 3 years ago

Change the MaxHealth variable to this

local Character = plr.Character or plr.CharacterAdded:Wait()
local MaxHealth = Character:FindFirstChildWhichIsA("Humanoid").MaxHealth
0
Why did my post get downvoted? SpectacularPavlos 86 — 3y
0
You're not using setasync and getasync correctly + you can't save 2 stats like that Cirillix 110 — 3y

Answer this question