Categories > Coding > Lua >
{Help} prevent a value from repeating
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!
I'm not lazy, I'm just highly motivated to do nothing. #I💚Dogs.
Replied
you COULD make a table of those who where printed and check if they have been printed
Cancel
Post
"Building blocks of imagination, united in the virtual realm, where creativity thrives and friendships ignite. Welcome to the Roblox revolution!" - chatgpt
Replied
I tried but I'm stupid using tables and the code doesn't work :(
However, I will try it once again.
Cancel
Post
I'm not lazy, I'm just highly motivated to do nothing. #I💚Dogs.
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
Cancel
Post
"Building blocks of imagination, united in the virtual realm, where creativity thrives and friendships ignite. Welcome to the Roblox revolution!" - chatgpt
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()
Cancel
Post
https://cdn.discordapp.com/attachments/877610317037858846/975469974405673041/Signature.png
Replied
Cancel
Post
I'm not lazy, I'm just highly motivated to do nothing. #I💚Dogs.
Replied
make a table, like this
local t = {}
t[object.Text] = true
Cancel
Post
https://cdn.discordapp.com/attachments/1023423265160560745/1132948683747500092/Frame_12x.png
Users viewing this thread:
( Members: 0, Guests: 1, Total: 1 )
Cancel
Post