I am trying to achieve a working datastore script but this error just randomly showed up. This code will return nil because for some odd reason this function isn’t finding any datastore.
player.CharacterRemoving:Connect(function(character)
--local character = player.Character
print("started")
local dataStore = DataStore.find("Player", player.UserId)
print(dataStore)
if dataStore == nil then print("dtaastore dont exist") end
print("passed checks")
print(dataStore)
print(dataStore.Value.CurrentlyLoaded)
print(player.Character)
if dataStore.Value.CurrentlyLoaded then
print("entered if")
local HumanoidRootPart = character:FindFirstChild("HumanoidRootPart")
print("found hrp")
if HumanoidRootPart then
local position = HumanoidRootPart.Position
print(position)
dataStore.Value.Cframe.Position.x = position.x
dataStore.Value.Cframe.Position.y = position.y
dataStore.Value.Cframe.Position.z = position.z
dataStore.Value.CurrentlyLoaded = false
print(dataStore.Value.Cframe.Position)
else
print("humanoid rootpart not found")
end
end
end)
The error I was getting was an attempt to index nil with “Value”. Because Value doesn’t exist because it can’t find the data store. I know this because it is outputting, “datastore don’t exist”, which you can see I put into the code