Increment datastore dont work

Hello. I currently scripint a system where when the player click on a part, his gain money. But the system wont work and I dont know why, can you help me ?

local DataStoreService = game:GetService("DataStoreService")
local gold = DataStoreService:GetDataStore("DataStore")
local clickDetector = script.Parent.ClickDetector

clickDetector.MouseClick:Connect(function(player)
		local success, newGold = pcall(function()
			return gold:IncrementAsync(player.Name, 1)
		end)

		if success then
			print("New Gold:", newGold)
		end
end)

Can you try removing the if check? This would print the error if any occurs.

I remove it but nothing, no error.

Can you put a print right after the click detector connection?

1 Like

nothing too … and dont understand why

Can you show me the hierarchy of the workspace?

1 Like

this ? image

Ah. I see. You cannot use a LocalScript to alter datastores. Consider switching to Script.

1 Like

oh yes, stupid error haha thank you !