Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Leaderstats value doesn't save upon adding a value?

Asked by 4 years ago

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 LocalScriptin 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

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

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.

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! RazzyPlayz 497 — 4y
Ad

Answer this question