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

How can I create a datastore that saves a players progress-?

Asked by 2 years ago

Rest of Title: when the player leaves but loads the data back when they rejoin the game

So my tycoon format and layout is based off of GamerM8's Tycoon Series, I have tried looking at other videos of how to make a data saving datastore and modify it to try and save the tycoon I am using/made. The problem is, is that I don't know how to save and reload like droppers, walls, and stuff.

This is the buying function:

01for i,v in pairs(Buttons:GetChildren()) do
02    local NewItem = BoughtItems:FindFirstChild(v.Item.Value)
03    if NewItem ~= nil then
04        Items[NewItem.Name] = NewItem:Clone()
05        NewItem:Destroy()
06    else
07        v.Transparency = 1
08        v.CanCollide = false
09 
10        v.ButtonPart.BillboardGui.TextLabel.Visible = false
11 
12    end
13    if v:FindFirstChild("Dependency") then
14        coroutine.resume(coroutine.create(function()
15            v.ButtonPart.Transparency = 1
View all 39 lines...

And this is my Data saving script (its in the same script)

01local DataStoreService = game:GetServices("DataStoreService")
02 
03local PlayerData = DataStoreService:GetDataStore("PlayerData")
04local UserOwnsTycoon = false
05local data = {}
06 
07game.Players.PlayerAdded:Connect(function(player)
08    UserOwnsTycoon = false
09    while true do
10        if player.leaderstats.OwnsTycoon == true then
11            UserOwnsTycoon = true
12            break
13        end
14    end
15    while true do
View all 31 lines...

This is what the model layout looks like, and the items in "BoughtItems" are not there until you buy them

Can anyone please help me? And last note, this is based off of GamerM8s Tycoon Series.

1 answer

Log in to vote
0
Answered by 2 years ago

maybe change newitem to the localplayers leaderstats and make a model of the tycoon and also include that in the datastore

0
Hey, I recommend watching Gamer8s series so you can know the entire thing so its more understanding if you know the answer to my problem. Joint_Ventures 5 — 2y
Ad

Answer this question