I was wondering how to make a save so if I say like, :givepoints MrRichGuy0210 500, after I leave it would save or atleast something like that, please dont hate me if it's a stupid question, im a noob to scripting.
01 | --Top of script |
02 | local datastore = game:GetService( "DataStoreService" ):GetGlobalDataStore() |
03 |
04 | --In OnChatted event: |
05 |
06 | --'name' (of target player) and 'amount' should be defined at this point (in chat you suggested you were editing an "admin" style script so I hope you can do this part) |
07 |
08 | --We want to convert 'name' to 'userId' because names can change |
09 | local success, userId = pcall ( function () return game.Players:GetUserIdFromNameAsync(name) end ) |
10 | if not success then return end --target user does not exist |
11 | --DataStore |
12 | datastore:IncrementAsync( tostring (userId), amount) |
13 |
14 | --If you wanted to use PlayerPoints, you'd use the following instead of the datastores: |
15 | game:GetService( "PointsService" ):AwardPoints(userId, amount) |