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

why is my game not auto saving the wins?

Asked by 8 years ago

hi scripter, so, ive just made a auto save and leaderboard (on top of screen) But the save does not save... If you want to see it, here you go! https://www.roblox.com/games/722511272/Jumpy-racing-Under-construction But what am I doing wrong?

leaderboard

1game.Players.PlayerAdded:connect(function(plr)
2    local stats = Instance.new('IntValue', plr)
3    stats.Name = 'leaderstats'
4    local Points = Instance.new ('IntValue', stats)
5    Points.Name = 'Wins'
6end)

OrderedDataStore AutoSave

01local DSService = game:GetService('DataStoreService'):GetDataStore('Hamburger223232')
02game.Players.PlayerAdded:connect(function(plr)
03    -- Define variables
04    local uniquekey = 'id-'..plr.userId
05    local leaderstats = Instance.new('IntValue', plr)
06    local savevalue =  Instance.new('IntValue')
07    leaderstats.Name = 'leaderstats'
08    savevalue.Parent = leaderstats
09    savevalue.Name = 'Wins'
10 
11    -- GetAsync
12    local GetSaved = DSService:GetAsync(uniquekey)
13    if GetSaved then
14        savevalue.Value = GetSaved[1]
15    else
View all 27 lines...

I hope you can help me out! thanks! good luck with other scripting!

-Gamer_io

0
This is not an ordered data store this is a global data store. User#5423 17 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

Paste this in a normal script inside of "ServerScriptService"

01GetService = game:GetService("DataStoreService")
02local Storage = GetService:GetDataStore("Hamburger223232")
03 
04game.Players.PlayerAdded:connect(function(Player)
05    --LEADERSTATS--
06    local User = Player.userId
07    local UserKey = "User_"..User
08    local SavedData = Storage:GetAsync(UserKey)
09    local Stats = Instance.new("IntValue", Player)
10    Stats.Name = "leaderstats"
11 
12    local Wins = Instance.new("IntValue", Stats)
13    Wins.Name = "Wins"
14    Wins.Value = 0
15 
View all 30 lines...

Already Tested it and it works great!

0
Be sure to check off the "Answered" box so I can get some points. SilentGalaxZy 53 — 8y
0
Thanks, it realy helped me! Gamer_io 14 — 8y
Ad

Answer this question