Remember that shorter code doesn’t necessarily mean more performant. This is about as performant as this code will get.
Now, if this is more of a question of style or readability than performance; then please get back to me so I can give a few points (although, all of them will be subjective as code style is. The code snippet provided isn’t “bad” by any means).
Looking at your current code, you have much more to worry about before considering to make it shorter.
Usage of Instance.new()
Refer to this:
No Retry or Fail Safe Mechanism
Utilize pcalls so you can check whether the datastore services are operational or not, otherwise you are risking complete data loss.
Don’t use SetAsync to update player data
SetAsync is a destructive function. UpdateAsync will allow you to backup player data etc.
Uncontrolled Data Saving
It’s not a good practice to update player data every time a change is made. You should update data in intervals otherwise you’ll hit datastore rate limits pretty quickly.
Set the parent of your created instances after changing their properties. The second argument of Instance.new() should only be used when you’re not going to set any properties.
You do not have to constantly save a new value to the datastore when the cash is changed, you can just save it into a table then save the data when the player leaves. Datastore calls should use pcall or they can error.
SetAsync can be used but if you need to worry about the previous value, you can use UpdateAsync.
Make players a service, don’t use deprecated functions. Use :Connect instead of :connect. Always parent last, not first since parenting it first is an inefficient way.
Shorter code = less bytes. It may be good to have shorter code but don’t expect some performance boost on the code unless you are dumping down from 800-4000 letters of code to 100-200.
Your CPU’s clock speed is also responsible for how fast it reads the code.
Example:
What to do:
local exampleFolder = Instance.new("Folder")
exampleFolder.Parent = player
What NOT to do:
local exampleFolder = Instance.new("Folder, player")