Data-store isent saving

Helo, so I am making leaderstats for my game. Im trying to use datastore service but its not working. the code I made. The error is some where above line 37. Please help thanks

1 Like

Did you allow Studio access to API services? You can do this in Game Settings > Options > Enable Studio Access to API Services.

Also, make sure to put your code in a code block, rather than an image. It makes it much easier to read and try and resolve the issue.

2 Likes

I am having the exact same issue, and I verified that access to API was enabled

local datastore = game:GetService("DataStoreService")

game.ReplicatedStorage.exploiter.OnServerEvent:Connect(function(player)
	local exploiterStore = datastore:GetDataStore("isExploiter",player.UserId)
	exploiterStore:SetAsync(player.UserId,1)
	print(exploiterStore:GetAsync(player.UserId))
	player:Kick("Exploiting.")
end)
1 Like

@gridgalaxy

Are you trying to print the UserId, or the key?

the value of exploiterStore (which should be 1)

@NotDeveloperKitty

I’m not seeing any issues with your code. It’s printing “1” in the output for me. Are you getting any errors in output?

image

Firing event was from the localscript that I created to test it.

game.ReplicatedStorage.exploiter:FireServer()

@gridgalaxy
If I had to guess, I would say that the issue is originating from whatever localscript is firing the event on the client.

nope ill try…

@YumReesesPuffs
At line 43, I think that you made a mistake by accidentally typing:

plr.UserId.."-oints", 

Whereas at line 25, you were attempting to get:

plr.UserId.."-points",
1 Like

LOL your right ima go fix that

It works thanks…