Local dataStore = DataStore.find("Player", player.UserId) returns nil using Suphis Datastore module

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

1 Like

Did you open the datastore before using it?

Hi, yes i did.


local function StateChanged(state, dataStore)
	while dataStore.State == false do
		if dataStore:Open(template) ~= "Success" then
			task.wait(6) 
			print("datastore didnt open")
		end
		print("datastore opened")
	end
end
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.