#Just for know is this correct or nah!

1 messages · Page 1 of 1 (latest)

sharp wing
#

I'm doing this for check if player has all badges

grand vale
sharp wing
#

no

#

like this

gusty niche
#

no, this is really bad

grand vale
#

Oh, oh...

grand vale
sharp wing
grand vale
#

Too much nesting.

sharp wing
#

the best option is make a property table

#

but idk how do it

#

if it uses for _,v in pairs or other thing idk

grand vale
#

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.

sharp wing
#

ok

#

i will make something here and u see if this is correct or nah

grand vale
#

At least that's the best way I can come up with on phone at 2am.

gusty niche
#

yes, but annotate that pairs and ipairs are useless in luau

void coral
#

use them

grand vale
sharp wing
gusty niche
grand vale
bold herald
#

bruh instead of using if statement a lot you can just do this instead

bold herald
#

why

void coral
gusty niche
#

depends on how you're going to

sharp wing
#

like that thing i did, idk how do it

void coral
gusty niche
#

if its just a code show good but dont spoonfeed

bold herald
#

ok

#

so

sharp wing
void coral
bold herald
#

put all the badges into the table.

void coral
#

if you want ot loop in a table you simply put the table name

sharp wing
bold herald
#

and then loop through it

bold herald
#

whenever the player added

sharp wing
#

I SAW THAT

grand vale
gusty niche
void coral
#
local tableName = {1, "hi"}
for index, value in tableName do
  -- thread
end
void coral
grand vale
grand vale
sharp wing
#

wait guys im confuse

bold herald
#

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)

grand vale
sharp wing
grand vale
#

Ah wait

#

My bad

#

Telephone shifted text

void coral
sharp wing
sharp wing
modest valleyBOT
#

studio** You are now Level 7! **studio

grand vale
void coral
sharp wing
grand vale
void coral
sharp wing
void coral
grand vale
sharp wing
void coral
#

dont spoonfeed bro

sharp wing
#

omg

void coral
#

also thats not what he wanted

#

lmfao

bold herald
#

ok

void coral
#

thanks

grand vale
# sharp wing

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

bold herald
#

ok i will tell it one by one instead

sharp wing
# bold herald ok

Oh and thanks for trying, seeing here that you made this whole script just to help me

void coral
#

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.

bold herald
#

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?

grand vale
grand vale
void coral
#

guys yk ure just confusing him more right

sharp wing
void coral
#

no

grand vale
void coral
#

i mean yes but in the for loop you have to add 1 to badgecount only when the player has the badge

bold herald
bold herald
#

or use #to get all the length of a table.

grand vale
void coral
#

abd delete the while loop

sharp wing
#

oh my god

grand vale
#

A clutter 😅

sharp wing
#

guys i realize that the script is meant to be just for the client

sharp wing
#

yeah

#

bcz if the script will ecexute for everybody

grand vale
#

It blocks a section of a game, it shouldn't be local based?

void coral
#
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)
sharp wing
#

yeah but it doesnt change everything?

void coral
#

like this

grand vale
#

Otherwise players will cheat

sharp wing
#

so its just put everything inside a local script?

void coral
#

fuck no

grand vale
#

A normal script

sharp wing
#

ok

void coral
#

okay lets do it like this

bold herald
#

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 🙂

sharp wing
#

ok i will try do it

void coral
sharp wing
#

wait

#

all that

bold herald
#

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

void coral
#

no thats unresourceful

bold herald
void coral
#

it also creates bad habits

bold herald
#

alr

void coral
#

it makes 0 sense for server to handle something that is deisgnated for only the client

#

sure it may intervene when needed

grand vale
#

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.

void coral
#

but it isnt 99% of the tme

bold herald
#

i rarely use remote event that much tho..

#

i actually use Module script all the time..

void coral
sharp wing
#

so what did i do

grand vale
void coral
#

its not like the player can just give himself a bagde

#

or fake it

void coral
void coral
#

task.wait()

#

its your favourite while loop

sharp wing
void coral
#

the problem did not include nay other scripts, and i do not know the intentions of para so dont blame me

grand vale
void coral
#

making simple things complex is called overcomplication

#

as a scripter thats one of your worst enemies

sharp wing
void coral
#

ye

bold herald
#
badgeHandler.__index = badgeHandler


function badgeHandler.new() 
    local self = setmetatable({}, badgeHandler)
    return self 
end

return badgeHandler``` just make oop structure xd
sharp wing
grand vale
#

Let's leave it be for debate.

void coral
#

honestly checking if the player has all the badges every 5 seconds is straight bs but wtv

#

the guys learning

#

let him be

bold herald
#

i am still learning tho please teach me how to get into level 2 scripting

bold herald
#

because of my bad naming convetions, etc.

sharp wing
#

i have 1 year of script my life is in a while loop

bold herald
#

honestly, i'll get into level 2 scripting sooner because i am taking my cs next month

sharp wing
#

local life = false

bold herald
#

damn that's sad

#

i am taking my first year as cs next month btw

#

so good luck with me

sharp wing
sharp wing
grand vale
#

Let's stop complaining

bold herald
sharp wing
grand vale
bold herald
modest valleyBOT
#

studio** You are now Level 10! **studio

grand vale
#

I think about turning Unity

grand vale
bold herald
#

is learning OOP early good for cs?

#

i learn OOP in python aswel

#

and lua

grand vale
#

Basically do a localscript that checks every 5 sec if the player has x badges

grand vale
sharp wing
grand vale
grand vale
bold herald
#

i do HTML, CSS, JAVASCRIPT, + CSS FRAMEWORK THO 💀

sharp wing
bold herald
#

it was a bootstrap i think

bold herald
#

not a real programming language.

sharp wing
#

and some people call me a scripter

bold herald
#

gtg now

sharp wing
#

luciferius

grand vale
grand vale
grand vale
#

We will stay simple

sharp wing
#

the touch is for tp the player for another place

sharp wing
#

i didnt explained it

grand vale
sharp wing
bold herald
grand vale
#

I will sketch you a crude structure of how it is supposed to look like

grand vale
bold herald
#

i was joking let's make a fun game or simple game bro 🙂

bold herald
#

i was like 5 months but i guess still not enough to reach l2

grand vale
#

Arrows are the indents

grand vale
#

So for loop and the rest is inside player:added and the check is inside the for loop

grand vale
sharp wing
grand vale
#

You should

sharp wing
#

i cant use playeradded

grand vale
#

We don't want to overcomplicate

grand vale
#

Oh lol

#

Well

#

That changes things

sharp wing
#

what i do now

bold herald
#
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 ```
grand vale
bold herald
#

no need to use playeradded whne you are using local script..

grand vale
#

Good point you can use localplayer

#

3:42 am here am I

sharp wing
#

but is that right or not

grand vale
bold herald
#

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

grand vale
#

If the value provided is the one you expect

#

Hard asf

bold herald
#

just do transparency 1 to the portal if he has it simple

grand vale
#

Or tweens depending on what you want