Hi there. I am recently working on a script that a player buys a new level through a door
local Proxy = script.Parent.ProximityPrompt
Proxy.Triggered:Connect(function(player)
if (player.leaderstats.Ruby.Value >= 3) then
player.leaderstats.Ruby.Value = player.leaderstats.Ruby.Value - 3
Proxy.Enabled = false
script.Parent:Destroy()
script.Parent.SurfaceGui:Destroy()
end
end)
This is my script and it works the way I want but I cannot understand how to save this so that if the player joins again he will not have to buy again. Kindly Help
You’ll need to use the Data Store Service to create save data that checks for whether or not that the player has already gone to that level before.
local DataStoreService = game:GetService("DataStoreService")
local PlayerProgress = DataStoreService:GetDataStore("PlayerProgress")
local playerUserID = 505306092 -- placeholder
local playerLevel = 0 -- to check which level the user is on
local setSuccess, errorMessage = pcall(function()
PlayerProgress:SetAsync(playerUserID, playerLevel)
end)
if not setSuccess then
warn(errorMessage)
end
This code should help serve as an example, but I’d recommend that you do your own research and remember to add in the check that syncs the player’s level with their saved level when they rejoin.