#Just for know is this correct or nah!
1 messages · Page 1 of 1 (latest)
I need a bit more context, are you going to check every badge individually?
no, this is really bad
Oh, oh...
Yes
yeah i know
Too much nesting.
the best option is make a property table
but idk how do it
if it uses for _,v in pairs or other thing idk
I would go a route of making an array of badge ids and iterate over it. Save in a different var how many of these thw user has and compere the max amount and player's.
Yes
At least that's the best way I can come up with on phone at 2am.
Copy that
yes, but annotate that pairs and ipairs are useless in luau
Mostly use Ipairs but pairs for sorted arrays
idk how use break
is useless in luau
You shouldn't need to use break in this one?
bruh instead of using if statement a lot you can just do this instead
dont write a code
why
why use break
depends on how you're going to
like that thing i did, idk how do it
if its just a code show good but dont spoonfeed
looking now break doesnt make sense
:GetDescendants() is for objects, not for tables
put all the badges into the table.
if you want ot loop in a table you simply put the table name
so what is for tables?
and then loop through it
whenever the player added
I SAW THAT
Delete the while loop, and use just Badges
:GetDescendants is a method from Instances, which are tables
local tableName = {1, "hi"}
for index, value in tableName do
-- thread
end
A quick and simple explanation of for i,v loops. And one of the most used loops you will come across. So sit tight and watch this quick tutorial so you can improve your coding skills tenfold!
JOIN THE DISCORD SERVER! https://www.discord.gg/8HGp6RzEZF
Explanation 0:00
Understanding of for i,v loops 1:03
Examples 4:30
Outro 8:40
Songs Used:
LuK...
keyword instances
Just use engine reference or language one...
It returns a array of the instance's children (descendants)
wait guys im confuse
local allbadge = {...}
local BadgeService = game:Get("BadgeService") <- you get service
game.PlayersAdded... <-- connect for every player
for _, badge in pairs(allbadge)
check if the player join has all the badge or not
BadgeService:UserHasBsadgeAsync(plr.Userid, badge) what are you going to do if you have a badge or not?
end
end)
You check for the badge inside the for loop.
if the player doesnt have all badges the portal doesnt open
Pretty much
use a bool value to determine this
ok
** You are now Level 7! **
thanks brotha
still use pairs
why do you have strings in your table
IDK
Ids
"Badge1" is a number id for you?

i love this emoji
dont spoonfeed bro
omg
ok
thanks
Now, you need to make another variable wich is being incremented by 1 each time the player has a badge
And don't increment when they don't
ok i will tell it one by one instead
k
Oh and thanks for trying, seeing here that you made this whole script just to help me
anyway do these steps:
Determine the badges in a table
Mkae a boolean variable that determines if all badges are owned by the player
Use a for index, value in table loop to go through all the badges in the table and make an algorithm that determines if player has all badges and sets the bool variable to true if player has them all, if not then false duh
ultimately execute the algorithm that turns the portal on based if value is true or not.
are you going to check if the player finally completed all the badge so that the portal automatically opens every second?
that's why you are using while loop?
After you do this, after the for loop you just make a simple if statement that checks if x == AmountOfBadges
Good question
guys yk ure just confusing him more right
yes
is this what i need to do luciferius?
no
Yes, but no
i mean yes but in the for loop you have to add 1 to badgecount only when the player has the badge
make a variable for boolean till the badge count is equal to 5
ok
or use #to get all the length of a table.
First point, and the second is that the check needs to happen in PlayersAdded
abd delete the while loop
oh my god
A clutter 😅
guys i realize that the script is meant to be just for the client
It blocks a section of a game, it shouldn't be local based?
local Badges = {...}
local bCount = 0
local bService = game:GetService("BadgeService")
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(plr)
for _, v in pairs(Badges) do
-- thread
end
end)
yeah but it doesnt change everything?
like this
Otherwise players will cheat
so its just put everything inside a local script?
fuck no
ok
okay lets do it like this
if you want only the player who has all the badge then you should send a remote event that opens a portal for that client 🙂
Yes
oh i understand it now
ok i will try do it
or just this?
local Badges = {...}
local bCount = 0
local bService = game:GetService9"BadgeService")
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(plr)
for _, v in pairs(Badges) do
-- thread
end
end) you can do this tho 🙂 but you have to use remote event once the server detected that the player has all the badge
no thats unresourceful
yeah if it were a simple game it should be fine
no
it also creates bad habits
alr
it makes 0 sense for server to handle something that is deisgnated for only the client
sure it may intervene when needed
What I would do.
Have a detector (invisible part with canCollide off but canTouch true) which will be a trigger for us.
When player touches it, run a check.
When the player has sufficient exp/lvl/badges you open the portal via remoteEvent.
but it isnt 99% of the tme
i rarely use remote event that much tho..
i actually use Module script all the time..
or use a localscript
so what did i do
The check would be done on normal script (server side) to validate it and opening made on localscript
validating things here is deemed useless
its not like the player can just give himself a bagde
or fake it
make a local script check if the player has all the badges every 5 seconds, if they do, stop the thread in any way.
i can use debounce?
yes it is!
the problem did not include nay other scripts, and i do not know the intentions of para so dont blame me
That's why I admitted that it's probably a better way, I would make it more complex in a good way. Let's stay simple. 
making simple things complex is called overcomplication
as a scripter thats one of your worst enemies
ye
badgeHandler.__index = badgeHandler
function badgeHandler.new()
local self = setmetatable({}, badgeHandler)
return self
end
return badgeHandler``` just make oop structure xd
ok
I would make it save to player array/dictionary/class with player related vars to avoid any/all unnecessary checks. At least that's my reasoning.
Let's leave it be for debate.
honestly checking if the player has all the badges every 5 seconds is straight bs but wtv
the guys learning
let him be
i am still learning tho please teach me how to get into level 2 scripting
help me to get on lvl 1
because of my bad naming convetions, etc.
i have 1 year of script my life is in a while loop
honestly, i'll get into level 2 scripting sooner because i am taking my cs next month
local life = false
damn that's sad
i am taking my first year as cs next month btw
so good luck with me
and i have 4 years of studio and my builds look trash too
relax im bad bcz im lazy
Let's stop complaining
are you into networking system?
yeah i will not learn crying
Yyyy... I was bored. I program in cpp as hobby.
you can make good games with cpp bro
** You are now Level 10! **
I learnt it for UE but the documentation is shit, and I don't want to pay for courses
I think about turning Unity
Yes
Basically do a localscript that checks every 5 sec if the player has x badges
like this
Idk, I'm not even in higher edu yet. I learnt python, lua, cpp, dart (for flutter) and swift
and i was struggling with html some days ago
Scrap the check
It isnt even a programming language
i do HTML, CSS, JAVASCRIPT, + CSS FRAMEWORK THO 💀
what?
it was a bootstrap i think
it's a hypertext markup language bro
not a real programming language.
ah hell nah
and some people call me a scripter
gtg now
It's a coding language as it doesn't use logic
I meant the one with touched
no
We will stay simple
the touch is for tp the player for another place
Ah
No, wait
?
lets do vibe coding bro
I will sketch you a crude structure of how it is supposed to look like
Hell nah
i was joking let's make a fun game or simple game bro 🙂
how long have you been scripting?
i was like 5 months but i guess still not enough to reach l2
//your vars and array
Player:Added
-> For loop
->-> check if the player has badge if so increment a variable by one, otherwise do no.
->the rest
Arrows are the indents
please explain with code im dumb
So for loop and the rest is inside player:added and the check is inside the for loop
Truthfully couple of years but didn't have any serious undertakings in roblox studio, that's why I don't have anything to back my S2 claim.
im using a local script brotah
i cant use playeradded
We don't want to overcomplicate
what i do now
local allbadge = {...}
local badgeservice = game:GetService("BadgeService")
for _, badge in pairs(allbadge)
local badgeCounter = 0
if badgeservice:UserHasBadgeAsync(plr.Userid, badge)
badgeCounter += 1
end
end
if badgeCounter == #allbadge then
print("has all the badge whatever")
else
print("the player doesnt have all the badge")
end ```
Learn remoteEvents
no need to use playeradded whne you are using local script..
Ah right
Good point you can use localplayer
3:42 am here am I
but is that right or not
Should be g
dont use remote event if it is not necessary.. since you are opening a portal i think you dotn have to use remote event
you can just do it on the client
Yes, you need to learn sterelization then
If the value provided is the one you expect
Hard asf
This should be useable
just do transparency 1 to the portal if he has it simple
And cancolide off
Or tweens depending on what you want