#Object Value DataStore2

56 messages · Page 1 of 1 (latest)

boreal sequoia
#

local starterValue = game.ReplicatedStorage.Ladder
local currentStat = script.Name
local statFolder = "leaderboard"

game.Players.PlayerAdded:Connect(function(plr)
    
    local currentDatastore = datastoreModule(string.lower(script.Name), plr)
    
    repeat wait()
        
    until plr:FindFirstChild(statFolder) and plr:FindFirstChild(statFolder):FindFirstChild(currentStat)
    
    local function updateStat(updatedValue)
        plr:FindFirstChild(statFolder):FindFirstChild(currentStat).Value = updatedValue
    end
    
    if currentDatastore:Get() == nil then
        updateStat(starterValue)
    else
        currentDatastore:OnUpdate(updateStat(currentDatastore:Get()))
    end
    
    plr:FindFirstChild(statFolder):FindFirstChild(currentStat):GetPropertyChangedSignal("Value"):Connect(function()
        currentDatastore:Set(plr:FindFirstChild(statFolder):FindFirstChild(currentStat).Value)
    end)
end)```

It gives me this error:  Unable to assign property Value. Object expected, got string  -  Server - Ladder:16
Ladder is the name of the script
paper crystalBOT
#

studio** You are now Level 10! **studio

boreal sequoia
#

xd

final mural
#

@boreal sequoia what line is line 17?

boreal sequoia
#

plr:FindFirstChild(statFolder):FindFirstChild(currentStat).Value = updatedValue

boreal sequoia
final mural
#

What is currentStat?

#

A StringValue?

boreal sequoia
#

current stat is the name of the script

#

which is Ladder

high orbit
#

wha

final mural
#

So the script is called both CurrentStat and Ladder?

#

How’s that even possible

boreal sequoia
#

https://www.youtube.com/watch?v=wBobROFO6a8&t i watched this tutorial and tried making it an object value instead of string value

In this video, I will be teaching all of you how to save numbers, strings, and tables to DATASTORE 2 in Roblox Studio!

Intro video on Datastore 2: https://www.youtube.com/watch?v=Z9L1cA0eZaE

Datastore2 Model: https://www.roblox.com/library/1936396537/DataStore2-Data-Loss-Prevention-and-Caching

Join this channel to get special access to perks...

▶ Play video
final mural
#

So you tried to save an object in a datastore?

boreal sequoia
#

datastore2 to be exact

#

and yes

final mural
#

Doesn’t matter

high orbit
final mural
#

How are you planning on putting an object inside a table?

boreal sequoia
final mural
final mural
#

I recommend storing all of the assets the player is able to save in the RS

#

Then save the name

boreal sequoia
#

i dont know what im doing i never messed with datastores

high orbit
high orbit
#

And currentStat is a script?

boreal sequoia
#

brub

#

idk what do i do

final mural
#

Is CurrentStat a script?

boreal sequoia
#

name of the script

high orbit
#

I am pretty sure currentStat is not a script. The naming doesn't sound like it is and the fact it's not giving a error despite accessing "Value" property which it doesn't have

final mural
#

.Value or a script doesn’t exist

high orbit
#

Try removing .Value and see if it works. Since it won't take string and a object instead

boreal sequoia
#

Let me explain better what im trying to do, In my steep steps fangame i wanna save ladder skin so you dont have to go and equip it everytime so i just try to save a value on the player with the ladder he equipped and then when he joins get the value and put it in the value of the skin(the value on the image)

high orbit
boreal sequoia
#

ok

#

ServerScriptService.Datastore2.StatSaving.Ladder:16: Expected identifier when parsing expression, got '='

high orbit
#

You probably have a extra paranthesis

boreal sequoia
#

where?
plr:FindFirstChild(statFolder):FindFirstChild(currentStat).Value = updatedValue

high orbit
#

can u show the line?

boreal sequoia
#

i added back .Value

high orbit
boreal sequoia
high orbit
#

hmm

boreal sequoia
#

i hate saving stuff

#

so complicated

high orbit
#

it is a syntax error so hmm

#

Maybe u have a extra paranthesis somewhere else in the code

boreal sequoia
high orbit
#

lol