Datastore Not Working

So what I’m trying to do is set the data to 0 if the player does not have any data yet. If the player has data, it will set a value to it, but why is it giving an error? I am completely clueless

game.Players.PlayerAdded:Connect(function(p)
	local l0=Instance.new("BoolValue")
	local l1=Instance.new("BoolValue")
	local l2=Instance.new("BoolValue")
	local l3=Instance.new("BoolValue")
	if not game:GetService("DataStoreService"):GetDataStore("l0"):GetAsync(p.UserId) then
		game:GetService("DataStoreService"):GetDataStore("l0"):SetAsync(0)
		print('falisified')
	end
	local success, err = pcall(function()
		game:GetService("DataStoreService"):GetDataStore("l0"):GetAsync(p.UserId)
	end)
	if success then
		print(success)
	end
end)

image

1 Like

Publish your game, go in game settings, enable API Services From Studio in Options.

It was always on

Character Limit

1 Like

Hm?, try running the game in a public server instead of studio.

1 Like

That will not make an avail. I’ve tried it already

1 Like

What line does the error refer to?

Line 6
Charssssssssssssssssssssssssssssssssssss

1 Like

Do you have the datastore script on a different place instead of the main place?

I don’t understand?
What do you mean different game

1 Like

A universe/game has a main place and you can make other places in that universe/game

No, there is only one place and game

30 charsssssssssssss

1 Like

Interesting. must be a bug i guess, you can try rewriting it on a different script and see if that works