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

My Data store script not working in my simulator game?

Asked by 3 years ago

Hi i need help on DataStore Saving. I watched Alvin Blox's video on it and it dosent work for me, no errors are in output, so I dont know what the problem is. I think its a Synax error but I cant find the error PLEASE HELP P.S I put my datastore in my leaderstats script

Script:

local serverStorage = game:GetService("ServerStorage")
local DataStore = game:GetService("DataStoreService"):GetDataStore("DataStore3")
game.Players.PlayerAdded:Connect(function(player)


    local leaderstats = Instance.new("Folder")
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = player

    local strength = Instance.new("NumberValue")
    strength.Name = "Strength"
    strength.Parent = leaderstats

    local rebirths =  Instance.new("IntValue") 
    rebirths.Name = "Rebirths"
    rebirths.Parent = leaderstats

    local coins = Instance.new("IntValue")
    coins.Name = "Coins"
    coins.Parent = leaderstats


    local dataFolder = Instance.new("Folder")
    dataFolder.Name = player.Name
    dataFolder.Parent = serverStorage.RemoteData

    local debounce = Instance.new("BoolValue")
    debounce.Name = "Debounce"
    debounce.Parent = dataFolder

    local strengthData, rebirthsData

    local success,errormessage = pcall(function()

        strengthData = DataStore:GetAsync("strength-",player.UserId)
        rebirthsData = DataStore:GetAsync("rebirths-",player.Userid)

    end)
    if success then
        if strengthData then
            strength.Value = strengthData
            rebirths.Value = rebirthsData
        end
    end
end)

game.Players.PlayerRemoving:Connect(function(player)
    local success, errormessage = pcall(function()
        DataStore:GetAysnc("strength-"..player.UserId,player.leaderstats.Strength.Value)
        DataStore:GetAsync("rebirths-".. player.UserId.player.leaderstats.Rebirths.Value)
    end)






end)
0
Did you make sure API Services are turned on? RazzyPlayz 497 — 3y
0
whats that? Braftedr 0 — 3y
0
turn api services on in 'Configure Game' on your game in the 'Create' tab Omzure 94 — 3y

Answer this question