Stuck on only one key in dictionary

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

When a value has one of the keys which are true it should do an action/stop

  1. What is the issue? Include screenshots / videos if possible!

It’s only printing one at a time, then printing the next one when the value is changed to the other key

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I tried to re-edit the code multiple times but it’s the same issue, and I also tried looking something similar up

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

local mai = {
    
    
    
}


local omg = {
    
	["b"] = true,
	["a"] = true,
	["c"] = true,
	["u"] = false

}

for key, value in pairs(omg) do

if value == true then
    
table.insert(mai, key)
end
end
for i2,val in pairs(mai) do
    repeat wait() print(val)
        
until game.Players.LocalPlayer.Value == val
    end
1 Like

maybe because you are making repeat wait() it makes your script repeat the same thing until your required thing won’t happen

you can try this

local mai = { }
local omg = {
	["b"] = true,
	["a"] = true,
	["c"] = true,
	["u"] = false
}

for key, value in pairs(omg) do
	if value == true then
		table.insert(mai, key)
	end
end
for i2, val in pairs(mai) do
	spawn(function()
        repeat
		    wait()
		    print(val)
	    until game.Players.LocalPlayer.Value == val
    end) 
end

Yeah, this one kind of works, but as I said, it should stop when any of the keys is inserted into the value, not any of them (Thank you for the response anyway :slight_smile: )

oh try this then

local mai = { }
local omg = {
	["b"] = true,
	["a"] = true,
	["c"] = true,
	["u"] = false
}

for key, value in pairs(omg) do
	if value == true then
		table.insert(mai, key)
	end
end
local Finished = false
for i2, val in pairs(mai) do
	spawn(function()
        repeat
		    task.wait()
		    print(val)
	    until game.Players.LocalPlayer.Value == val or Finished == true
        Finished = true
    end) 
end

Oh, apparently this works, thank you so much <3 :).

1 Like

No problem make sure to mark it as solution if my answer helped you.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.