Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make a givepoints command save after I leave?

Asked by 8 years ago

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.

0
I meant while leaving, RIP MrRichGuy0210 17 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago
01--Top of script
02local 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
09local success, userId = pcall(function() return game.Players:GetUserIdFromNameAsync(name) end)
10if not success then return end --target user does not exist
11--DataStore
12datastore:IncrementAsync(tostring(userId), amount)
13 
14--If you wanted to use PlayerPoints, you'd use the following instead of the datastores:
15game:GetService("PointsService"):AwardPoints(userId, amount)
Ad

Answer this question