#While loop in function not able to detect a boolvalue changing values

19 messages · Page 1 of 1 (latest)

wraith bough
#

Hello, I'm making a script for a tool and in this script I made it so that when the player starts holding MB1, a power bar appears and starts to increase in power, but when the player releases MB1, the power bar is supposed to stop increasing its power. I'm trying to do that by making "InputEnded" change a boolvalue's value so that it can stop a while loop which is used to wind up a shot, except the while loop completely ignores it and keeps going. Any reason why?

#

this is a local script inside a tool which is located in StarterPack btw

winter prawn
#

inside the loop

#

check if boolvalue = false

#

then

#

break the loop

#

while is isHolding.Value == true do
shootPower.Value += 2
wait()
if isHolding.Value == false then
break
end
end

#

i think this gonna work

wraith bough
#

I'm gonna try to use remote events and see if that works

#

I just playtested and noticed that it's the "InputEnded" function that isn't changing the value to false

#

causing the while loop to never break

wraith bough
#

syntax mistake when I was typing the if statement for "InputEnded"

#

I forgot to type isHolding**.Value**

#

and it was just isHolding == true

#

solved it

#

works flawlessly now

#

but thanks for trying to help