Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make a givepoints command save after I leave?

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.

1 comment

0

I meant while leaving, RIP

1 answer

✓ Accepted answer
--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)

This discussion is preserved as it was. New answers, comments, and votes are closed.