#The script is not working and i don't know why

1 messages · Page 1 of 1 (latest)

lament carbon
void dragon
#

arrays are ipairs I believe

#

could be wrong

gleaming zephyr
gleaming zephyr
# lament carbon HELP

In that while loop, you're connecting to every clickable's Changed event over and over and over. That's bad.

lament carbon
#

ok

#

how i do it to work i just want that

gleaming zephyr
lament carbon
#

what a minute

#

like

#

i recoded it

#

and now is just one button

#

i really would like it to be 4 buttons

void dragon
#

one button works?

lament carbon
#

yeah

void dragon
#

Issue is you have a for loop with no wait

lament carbon
#

is not hard do that

void dragon
#

so it check all at once if v.Value = true

#

you only clicked one probably

#

so all 3 others are false

#

which returns false break end

lament carbon
#

my trouble is with more than one button

#

my studio crashed

void dragon
#

well yea

lament carbon
#

it didnt crash

void dragon
#

you don't have any task.wait inside for loop

lament carbon
#

i dont want to do this wait thing, i want something more optimized like check if the player pressed one of the buttons

void dragon
#

one of the buttons or all

lament carbon
lament carbon
#

just check when all buttons are pressed or when a button is pressed

#

i need this finished until tomorrow

#

this is a easter quest im making

void dragon
#

what is the Bool variable

lament carbon
#

is a boolvalue

#

when the player press the button it becomes true

#

like Click.MouseClick:Connect(function() BoolValue.Value = true

void dragon
#

basically you want something to happen if all 4 buttons are clicked

lament carbon
#

yea

#

thats what im looking for

#

but i cant figure it out

void dragon
#

you def need a task.wait tho

#

else gonna cause issues

lament carbon
#

ok

void dragon
#

have a while not AllClicked do

#

inside it make a for loop

#

with your clickables array

lament carbon
#

can u make a example of it?

#

its hard for me understand

#

im a newbie

topaz skiff
#

Output

topaz skiff
lament carbon
#

and like nothing

topaz skiff
#

Debug with print

lament carbon
#

im trying to recode it

lament carbon
#

im trying to do somenthing with "for i, v do"

void dragon
#

perhaps something like this?

lament carbon
#

i did this but it activates everytime when i click one of them like not everybody

gritty flickerBOT
#

studio** You are now Level 6! **studio

lament carbon
#

can u send to me it?

void dragon
#

sure

timid dagger
#
local clickables = script:GetChildren() -- an array of BoolValue's

local function checkAll()
    for _, v in clickables do
        if v:IsA("BoolValue") and not v.Value then
            return false
        end
    end
    return true
end

--TEST!!!
while task.wait(3) do
    if checkAll() then
        print("all are true")
    end
end
void dragon
#

issue is youre infinitely looping the check

gritty flickerBOT
#

studio** You are now Level 3! **studio

void dragon
#

your*

timid dagger
#
local clickables = {boolvalues here}

local prompt = Instance.new("ProximityPrompt")

local function checkAll()
    for _, v in clickables do
        if v:IsA("BoolValue") and not v.Value then
            return false
        end
    end
    return true
end

prompt.Triggered:Connect(function()
    if checkAll() then
        print("all are true")
    end
end)
gleaming zephyr
lament carbon
#

the problem was solved