Forum > Coding >

{Help} prevent a value from repeating

Syraxes_

Web Developer

vip

Posts: 1068

Threads: 30

Joined: Jul, 2021

Reputation: 63

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: 793

Threads: 54

Joined: Sep, 2021

Reputation: 21

Replied

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

  • 0

dead inside

Syraxes_

Web Developer

vip

Posts: 1068

Threads: 30

Joined: Jul, 2021

Reputation: 63

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: 793

Threads: 54

Joined: Sep, 2021

Reputation: 21

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

dead inside

Kura

kuraise

Posts: 135

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: 426

Threads: 32

Joined: Aug, 2021

Reputation: 54

Replied

@_realnickk too much spoonfeed he says >:[

  • 0

Owner @ https://altbot.win

The #1 Account Gen for Roblox

Syraxes_

Web Developer

vip

Posts: 1068

Threads: 30

Joined: Jul, 2021

Reputation: 63

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: 328

Threads: 17

Joined: Aug, 2021

Reputation: 37

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: 0, Total: 0 )