So, I'm making a simulator game and wondering how to make a restart button (GUI) that resets all the player's leaderstats data (data being points and prestige) Hope I can get some help on this :)
I am assuming here you are capable of making a GUI Button. The solution to this is straight forward, just set the DataStore data for the player to the default data when the player clicks the button. Since the GUI button would be client-side, you would need to send a remote signal to the server to do the data clearing.
For example, your scripts may look something like this:
-- local script local guiButton = reference.to.gui.button local remoteEvent = reference.to.remote.event guiButton.Activated:Connect(function(inputObject) remoteEvent:FireServer() end) -- server script local datastore = game:GetService('DataStoreService') local store_playerData = datastore:GetDataStore('playerData') local defaultData = { -- Set the default data Money = 0, Stats = 0, Level = 0, } remoteEvent.OnServerEvent:Connect(function(player) -- Get access to the player's datastore local playerKey = "Player_" .. player.UserId local success, err = pcall(function() store_playerData:SetAsync(playerKey, defaultData) end) if not success then print(err) end end)