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)