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

How Do I Access Datastore2 Data?

Asked by 4 years ago

I've made character creation GUI that stores your customised style and saves it. I want to take the saved data from the datastore so I don't have to customise my character again. How can I go about this? Also this is a server script

local DataStore2 = require(1936396537)

DataStore2.Combine("Customization", "Shirt", "Pants")

local function getData(player)

    local char = player.Character or player.CharacterAdded:Wait()
    local ShirtDS = DataStore2("Shirt")
    local shirt = char:WaitForChild("Shirt")

    shirt.ShirtTemplate = ShirtDS:Get()
end

getData()

Only error is: ServerScriptService.DataStore:7: attempt to index local 'player' (a nil value) Line 7 Maybe access the player in another way?

Answer this question