Categories > Coding > Lua >

{Help} prevent a value from repeating

Syraxes_

Web Developer

vip

Posts: 1307

Threads: 40

Joined: Jul, 2021

Reputation: 67

Posted

Hello!

 

Well in context I am trying to create a system that collects the names of the most wanted players. However the 'posters' are in different places so they will be repeated.

So an example of my code:

for _,v in pairs(game.Workspace.WantedPosters:GetDescendants()) do
	if v:IsA('TextLabel') and v.Name == 'Wanted' then
       print(v.Text)
	end
end

 

Console:

Implayer1

Implayer1

Implayer5

Implayer3

Implayer1 

 


 

So, how can I prevent Implayer1 from repeating and only returning once? I would appreciate your help, Thanks!

 

  • 0

I'm not lazy, I'm just highly motivated to do nothing. #I💚Dogs.

Posts: 1008

Threads: 66

Joined: Sep, 2021

Reputation: 20

Replied

you COULD make a table of those who where printed and check if they have been printed

  • 0

"Building blocks of imagination, united in the virtual realm, where creativity thrives and friendships ignite. Welcome to the Roblox revolution!" - chatgpt

 

Syraxes_

Web Developer

vip

Posts: 1307

Threads: 40

Joined: Jul, 2021

Reputation: 67

Replied

@crazy_cat

 

I tried but I'm stupid using tables and the code doesn't work :(

However, I will try it once again.

  • 0

I'm not lazy, I'm just highly motivated to do nothing. #I💚Dogs.

Posts: 1008

Threads: 66

Joined: Sep, 2021

Reputation: 20

Replied

@Syraxes_ wait, i have a function for searching tables for value and adding stuff to tables somewhere. once i find it i will reply

  • 0

"Building blocks of imagination, united in the virtual realm, where creativity thrives and friendships ignite. Welcome to the Roblox revolution!" - chatgpt

 

Kura

kuraise

Posts: 161

Threads: 3

Joined: Jun, 2021

Reputation: 5

Replied

@Syraxes_ Make a table and add everything then check if the name already exists with 

table.find()

and if it exists then do 

table.remove()
  • 0

 

https://cdn.discordapp.com/attachments/877610317037858846/975469974405673041/Signature.png

Posts: 511

Threads: 32

Joined: Aug, 2021

Reputation: 58

Replied

@_realnickk too much spoonfeed he says >:[

  • 0

Syraxes_

Web Developer

vip

Posts: 1307

Threads: 40

Joined: Jul, 2021

Reputation: 67

Replied

@_realnickk

 

Thanks You!

https://cdn.discordapp.com/emojis/719305986703228978.png

  • 0

I'm not lazy, I'm just highly motivated to do nothing. #I💚Dogs.

RiceUsesArchBtw

rice cracker

vip

Posts: 465

Threads: 19

Joined: Aug, 2021

Reputation: 39

Replied

make a table, like this

local t = {}
t[object.Text] = true

 

  • 0

https://cdn.discordapp.com/attachments/1023423265160560745/1132948683747500092/Frame_12x.png

Users viewing this thread:

( Members: 0, Guests: 1, Total: 1 )