ApeRuss
(ApeRuss)
May 10, 2021, 10:58am
#1
Alright so straight to the point, I’m working on membership system using module scripts (tables)
First table is the membership type, and second one is the membership duration
So when I go to my different serverscript, I try to make a value for the player and put the duration as it’s value, here’s my code, I don’t know what’s wrong with it, I did some research on the internet/devhub and I couldn’t come out with a solution:
1 Like
GalPlayss
(GalPlayss)
May 10, 2021, 11:14am
#2
platinum is the value let me explain
the table is looking like this
[1588610618] -- index {} -- and this is a table, and the table does not have a name
if i understood the thing correctly you should do
if v[1] == "Platinum" then
v[1] will be “Platinum”
if it helped please mark it as a solution
2 Likes
ApeRuss
(ApeRuss)
May 10, 2021, 11:16am
#3
Yeah but platinum here is not the problem, naming the value is the problem
1 Like
GalPlayss
(GalPlayss)
May 10, 2021, 11:18am
#4
the value is created? or no? is it just the value?
2 Likes
ApeRuss
(ApeRuss)
May 10, 2021, 11:19am
#5
The value creates it perfectly fine, but I’m trying to put the platinum.Value value as it’s expire date, which is “never” in the table
That’s why i tried v[2]
1 Like
GalPlayss
(GalPlayss)
May 10, 2021, 11:23am
#6
try maybe printing v or v[2] and see whats the problem
2 Likes
ApeRuss
(ApeRuss)
May 10, 2021, 11:25am
#7
It just prints nil but how would i get it the other way?
1 Like
caviarbro
(caviarbro)
May 10, 2021, 11:26am
#8
for k, x in pairs(yourindex) do
print(k, x)
end
1 Like
ApeRuss
(ApeRuss)
May 10, 2021, 11:27am
#9
Now it prints “1, platinum” but when i try v[2] it prints nil, ???
1 Like
caviarbro
(caviarbro)
May 10, 2021, 11:27am
#10
Because it works only for arrays.
2 Likes
ApeRuss
(ApeRuss)
May 10, 2021, 11:27am
#11
So how would i get the value, ??
1 Like
GalPlayss
(GalPlayss)
May 10, 2021, 11:28am
#12
Ohhh coz v is the table and it will be “Platinum”, you don’t need a loop for that you can do
local PlayerTable = table[player.UserId]
if PlayerTable[1] == "Platinum" then
etc...
value = PlayerTable[2]
2 Likes
caviarbro
(caviarbro)
May 10, 2021, 11:30am
#13
You need to use the for loop again. Or make it like this:
[1111] = {Time = 10, Name = "Awesome"}
for i, v in pairs(yourtable) do
print(v["Name"])
end
2 Likes
ApeRuss
(ApeRuss)
May 10, 2021, 11:30am
#14
Yeah but I’m gonna automate it later on, so it names the name of the value the first value of the table, so it does need a loop
1 Like
GalPlayss
(GalPlayss)
May 10, 2021, 11:31am
#15
so you can do
local table = {
[player.UserId] = {"Platinum" = {Expiration = "Never"}}
}
and it will work fine
2 Likes
ApeRuss
(ApeRuss)
May 10, 2021, 11:34am
#16
You mean just add a variable to each table, the code you just wrote confused me, would it work like this?
1 Like
caviarbro
(caviarbro)
May 10, 2021, 11:34am
#17
Yes this is probably best way to do it.
2 Likes
ApeRuss
(ApeRuss)
May 10, 2021, 11:36am
#18
But wait, what’s the difference, it confuses me mad hard now.
1 Like
GalPlayss
(GalPlayss)
May 10, 2021, 11:36am
#19
then you wont need a loop… you will just do
table[player.UserId].Type or Expiration
2 Likes
I’m so confused, whenever somebody buys a membership you are going to manually add them to a table? that doesn’t make sense.
2 Likes