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

My SaveDataStore service isnt even working idk why please help?Please?

Asked by 3 years ago

For some reason i copied a whole tutorial i even enabled api services and it isnt even working i keep getting this stupid error: ServerScriptService.DATA.MainData:38: ServerScriptService.DATA.MainData:32: attempt to index nil with 'StandPower'

heres the serverscript

local service = game:GetService("DataStoreService")
local datastore = service:GetDataStore("Stand")
game.Players.PlayerAdded:Connect(function(player)
    local stander = Instance.new("Folder",player)
    stander.Name = "StandFolder"

    local standname = Instance.new("StringValue",stander)
    standname.Name = "standname"
    standname.Value = "None"

    local data
    local success, errormsg = pcall(function()
        data = datastore:GetAsync("Player_"..player.UserId)   
    end)

    if data ~= nil then
        standname.Value = data
    else
        warn(fail)
    end
end)

game.Players.PlayerRemoving:Connect(function(player)
    local success, errormsg = pcall(function()
        datastore:SetAsync("Player_"..player.UserId,player.StandFolder.standname.Value)   
    end)
    if success then
        print'done'
    else
        print'fail'
        error(errormsg)
    end
end)
0
SAME BRUH!!! i didnt get help tho ReaperMr 0 — 3y
0
rip TheLegacyOfReaper 14 — 3y
0
If your just testing in studio I suggest testing it in the actual game itself, because I had a similar problem where there where no errors to the code but it worked in the actual game Rayguyban2 89 — 3y
0
Still doesnt work TheLegacyOfReaper 14 — 3y
0
Is that the whole script? RazzyPlayz 497 — 3y

Answer this question