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

Leaderstats value doesn't save upon adding a value?

Hello,

I'm currently working on an RPG MMO game, and I'm trying to make a quest system with an exchange. For example: Earn 20 gold for 300 xp. So I have a LocalScript in the TextButton in a ScreenGui and the script is:

local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
	if player.leaderstats.MobKills.Value >= 50 then
		player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 10000
		player.leaderstats.MobKills.Value = player.leaderstats.MobKills.Value - 50
		script.Parent.TextSize = 22
		script.Parent.Text = "Quest Commpleted"
		script.Disabled = true
	end
end)

So if the player has 50 MobKills then they can exchange for 10000 Coins, this works and it updates, however it doesn't save, so when the player rejoins the game it will go back to what it was before if they hadn't clicked on the quest.

I'm not sure why it doesn't save, and I would really appreciate some help. Thanks!

1 answer

✓ Accepted answer

You're going to have to use datastores to save data instead, this is (probably) the only way to save data when a player exits. Link: Datastores DM me at The Overseer#0001 if you need any help. Datastores only work if you have a script not a localscript, so you will have to use remote events.

1 comment

0

No worries! I found out a solution, I already have a Data Store for the leaderboard, the issue was that it was only this script that didn't save, so I had changed over to a normal script. Thanks for the reply anyway!

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