basically, i'm trying to make it so when a bool value is true, it waits 5 seconds and then continues what the tool was going to do, but when its false, it instantly breaks and stops what it was going to do, but i just cant figure it out, it either does it instantly or doesn't do it at all, instead of waiting 5 and then doing it and breaking, any fixes? this is my code
holding.Changed:Connect(function()
if holding.Value == true then
for i = 0, 5 do
if holding.Changed then
print("ended prematuraly")
return
else
print("healing in progress")
wait(1)
end
end
end
after all the ends the "if holding.Value == true then" continues and heals the player

11 comments
well i just tested it and what its doing is waiting 5 seconds and working, but if i stop holding click, it keeps going, what i'm trying to do is make it so when you stop holding click, it returns back to waiting for the function to be called and doesnt execute the healing code
You shouldnt need to make it stop since, I assume, you put it in an event like you did with your own code.
If you didnt I probably should have mentioned that
basically how my code runs is, there is an event that fires everytime an input starts/ends using userinputservice, and detects if the player is holding mouse1, and then turns the bool on/off
the bool is a BoolValue object correct?
yeah its the same, do you want me to send you the client/server parts of the bool on/off switch?
I think I know what is going wrong, let me fix the code
I just added the proper stuff for the BoolValue, now all that you need to do is replace "Instance.new("BoolValue")" with whatever BoolValue you are using
still does the same thing, very strange
Yea, ill have to test it myself when i get the chance.
alrighty then, tell me when you test it and if theres anything wrong on your end