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

I got my data save button to work but i cant get my load button to work HELP?

Asked by
abrobot 44
6 years ago
local repStorage = game:GetService("ReplicatedStorage")
local remote = repStorage:WaitForChild("RemoteSAVE")
local DataStore = game:GetService("DataStoreService")
local SaveCash1 = DataStore:GetDataStore("ExampleDataStore")
local RemoteLOAD = repStorage:WaitForChild("RemoteLOAD")


game.Players.PlayerAdded:connect(function(player)
    local leader = Instance.new("Folder",player)
        leader.Name = "leaderstats"
            local Bricks = Instance.new("IntValue",leader)
                Bricks.Name = "Bricks"
                    Bricks.Value =  0
                        SaveCash1:SetAsync(player.UserId, Bricks.Value)




remote.OnServerEvent:connect(function(player )
    print(Bricks.Value.. "Saved")
    SaveCash1:SetAsync(player.UserId, Bricks.Value) 
end)



RemoteLOAD.OnServerEvent:connect(function(player )
    Bricks.Value = SaveCash1:GetAsync(player.UserId)
end)




wait(5)
    for i = 1, 1000 do
        wait(.5)
            game.Players.Abrobot.leaderstats.Bricks.Value = game.Players.Abrobot.leaderstats.Bricks.Value + 1   
        end
    end)

0
Wth is this script, you also forgot an end after line 14 User#20388 0 — 6y
0
Another problem is that your saving the moment the player joins wich means he won't have time to load in his values and it wiill get overwritten User#20388 0 — 6y
0
I don't know what you mean about the missing end, but i see sew what you meant at line 15 and i fixed it i must have forgot to delete it. abrobot 44 — 6y
0
Thank you so much its people like you that are what makes scripting helpers great. abrobot 44 — 6y
0
Oh that end is at lind 38 btw abrobot 44 — 6y

Answer this question