I originally took this to ROBLOX's SH but no-one's suggestions seemed to help.
What I am trying to do is create a player level which currently increments when you click script.Parent, a brick with a ClickDetector.
Also, it works in Solo Mode. Nothing else.
local datastore = game:GetService("DataStoreService"):GetDataStore("PlayerLevel") wait(10)--Too lazy to check for character properly script.Parent.ClickDetector.MouseClick:connect(function(plr) local key = "user_"..plr.userId local gui = plr.PlayerGui.MainUI.plrLevelGui.PlrLvlNum datastore:IncrementAsync(key, 1) gui.Text = datastore:GetAsync(key) end)
Here's how the wiki demonstrates use of IncrementAsync.
local number = DataStore:IncrementAsync(key, 1)
That would increase the DataStore's value by one, and also return the value of the new value, since GetAsync doesn't yield immediately after IncrementAsync is used. Here's a fixed version of your script:
local datastore = game:GetService("DataStoreService"):GetDataStore("PlayerLevel") wait(10) script.Parent.ClickDetector.MouseClick:connect(function(plr) local key = "user_"..plr.userId local gui = plr.PlayerGui.MainUI.plrLevelGui.PlrLvlNum local newValue = datastore:IncrementAsync(key, 1) gui.Text = tostring(newValue) end)
This was taken from the wiki and edited to fit your needs. If there's any problems, comment. If this works, upvote!