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
--Top of script
local datastore = game:GetService("DataStoreService"):GetGlobalDataStore()

--In OnChatted event:

--'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)

--We want to convert 'name' to 'userId' because names can change
local success, userId = pcall(function() return game.Players:GetUserIdFromNameAsync(name) end)
if not success then return end --target user does not exist
--DataStore
datastore:IncrementAsync(tostring(userId), amount)

--If you wanted to use PlayerPoints, you'd use the following instead of the datastores:
game:GetService("PointsService"):AwardPoints(userId, amount)
Ad

Answer this question