Hello, I tried doing a script to save datas on a table but something weird happens
a part of the script:
1 | game.Players.PlayerRemoving:Connect( function (Player) |
2 | local StatsValue = { } |
3 |
4 | for _,v in pairs (game.ReplicatedStorage.Stats:GetChildren()) do |
5 | print (v.HasGot.Value) |
6 | local New = { [ 'Material' ] = v.Name, [ 'HowMuch' ] = v.Value, [ 'Unlocked' ] = v.HasGot.Value } |
7 | table.insert(StatsValue,New) |
8 | end |
9 | end ) |
And the value is actually printing "false" but when I want to insert it in "Unlocked" i get the error "HasGot is not a valid member of StringValue"
I don't understand why :(
Well, I am not sure what is causing the HasGot
not the member of StringValue
. But, other from that, there is a major issue. You cannot add Dictionaries
to the table using table.insert
. the following code might help :
01 | game.Players.PlayerRemoving:Connect( function (Player) |
02 | local StatsValue = { } |
03 |
04 | for _, v in pairs (game.ReplicatedStorage.Stats:GetChildren()) do |
05 | print (v.HasGot.Value) |
06 | StatsValue [ 'Material' ] = v.Name |
07 | StatsValue [ 'HowMuch' ] = v.Value |
08 | StatsValue [ 'Unlocked' ] = v.HasGot.Value |
09 | end |
10 | end ) |
If the problem related to HasGot
further continues, please comment and lemme know. If you want realtime help, you can ask for my discord DM.