#This isn't working and i don't know why
1 messages · Page 1 of 1 (latest)
are the Clicked variables Values? What are they
they are a bool value
Then you need to do Clicked1.Value to check the value of the BoolValue
It happens, don't worry
holy nested if statements
Is this a server script or local script?
server
Put them all in a table and make a for loop instead all of these if statements 😭
Do you set the bool values on the server too? Like when they're clicked?
yes
Local table = {clicked,clicked2 etc}
local allclicked = true
for I,v in pairs(table) do
if v.Value then allclicked= true
else allclicked = false return end
end
Lets see if the Triggered event is running by adding a print("hello world") and see if you can find it in the output
Format that
Sure thing
nothing below the if's is working
local allclicked = true
for I,v in pairs(table) do
if v.Value then allclicked= true
else allclicked = false return end
end```
Double check for mistypos
Are sure the BoolValues are being set? Check those values in the explorer and see what happens when you click them
the value becomes true
for all of them
i will try that
Do break instead of return
like that?
** You are now Level 5! **
dang!
Ye
It loops thro every clicked variable and if one of them is not true then it'll set allclicked to false and not continue the for loop
My suggestion only makes the code smoother/easier to understand, don't think it'll fix anything
oh thats why it didnt work
Also place the table and the allclicked boolean outside of the while loop
thanks for all the help
local Collisions = script.Parent.Collisions
local GreenPart = script.Parent.GreenButton
local Prompt = GreenPart.ProximityPrompt
local stickmasterluke = script.Parent.Stickmasterluke
local sticknoid = stickmasterluke.Sticknoif
local AllClicked = false
task.Spawn(function()
while task.wait() do
for I,v in pairs(clickables) do
If v.Value == true then AllClicked = true
else AllClicked =false break end
end
end)
prompt.Triggered:Connect(function()
if AllClicked then
sticknoid:TakeDamage(100)
end
end)```
Double check misstypos too sense all of this code is from memory
Not a capital s I think
Actually you could do
v.Changed:Connect(function()
for I,v in pairs(clickables) do
if v.Value then AllClicked = true
else AllClicked = false break end
end
end
end
Instead of the entire spawned function
Less lag, only fires when a then value is changed instead of every ms
thats pretty bad, I think the objective of the one who created the post is do a thing when all are clicked right? @eager heart
yeah sorry
i was on school