Deleted.Deleted.Deleted.Deleted

Deleted.Deleted.Deleted.Deleted

What is match. Please show us the reference.

Match is not a thing; And why are you trying to get index 2 of the players UserId-? :thinking:

local match: {

“127942174” = {

“number1”
“number2”
}

}

It prints the Number what is inside but with If it dont works

No i have the “”
because of the tostring

1 Like

This represents the user id in that dictionary.

if match[tostring(player.UserId)]["100"]

This represents the ‘code’ the number 100

1 Like

But i dont need the match[tostring(player.UserId)] i need the match[tostring(player.UserId)][2] because i want to check if the number in 2 is equal to code

I will try it, Thanks


local match = {
	["127942174"] = {
		100;
		200;
	}
}

game.ReplicatedStorage:WaitForChild("RemoteEvent").OnServerEvent:Connect(function(player, code)
	if match[tostring(player.UserId)][2] == code then -- "2" here is 200
		print("1")
	end
end)

It looks like your keys inside that dictionary have table as their values.

local match = {
	["127942174"] = {
		100;
		200;
	}
}

print(match["127942174"][1]) -- 100
1 Like

table.insert(match[tostring(player.UserId)], Number1)
table.insert(match[tostring(player.UserId)], Number2)

match[tostring(player.UserId)][2] = math.random(1,9)

if match[tostring(player.UserId)][2] = code then
print("")
end

But thats not working


Table.insert doesnt work with dictionaries.
Instead, you’d need to define number1 with a key and value, like this -

match[tostring(player.UserId)]["number1"] = 1
1 Like

Look here. Try to adjust this with your code.
Remember, since your ‘match’ is a dictionary, you cant add items using table.insert, you’d need to define keys with values.

2 Likes

But it works when i send the number with remote event to a client and when i print it or change the Number in it

I tried it that also dont works

But thank you for your help i will see where the Problem is at

What is your currently code? Have you changed something?

1 Like

I tried it again and when i do this:

game.ReplicatedStorage:WaitForChild("RemoteEvent").OnServerEvent:Connect(function(player, code)
if match[tostring(player.UserId)][2] = code then
print("Works")
end
end

That dont works

game.ReplicatedStorage:WaitForChild(“RemoteEvent”).OnServerEvent:Connect(function(player, code)
local code2 = 123
if match[tostring(player.UserId)][2] = code2 then
print(“Works”)
end
end

This Works

With a Variable the script dont works, its like he cant read the Number inside the Variable

if match[tostring(player.UserId)][2] = 123 then
print("Works")
end
local dictionary =  match[tostring(player.UserId)]
if dictionary[2] == 123 then
   print("Works")
end

Try this.

1 Like