ok first of all, to add to your knowledge of scripting, you can increment or un increment using
1 | script.Parent.Value + = 1 |
3 | script.Parent.Value - = 1 |
its easier, second, loook for any errors in your code and try your best to figure it out and only poste on this website as a last resort, many people here post without looking up the answer and its so painfully obvious that posting a question that has litteraly 600 results if oyu type the word is jsut annoying. anyway, i see a few problems here.
You have 2 if statments, and i only see 1 end.there should be another end after the last end so everything runs if the game is loaded.
Also, the if statement that checks to see if the value is 0 only runs one time, its not inside of any loop, so it wont work, you should put it inside the while loop so it checks the value and then adds 1 if its not 0, and if it is 0, then it disables the script, you can use elseif for that:
04 | if script.Parent.Value = = 0 then |
06 | script.Disabled = true |
08 | elseif script.Parent.Value > 0 then |
10 | script.Parent.Value = script.Parent.Value - 1 |
- Whenever you check if its 0, just in case it breaks or goes too fast and it ends up going to negative numbers (which sometimes happens), put <= 0, which is less than or equal to 0, so even if it goes to a negative number, it will still work. always do this please.
So if im not mistaken, basically you forgot an end, and you placed the if in the wrong place, your code should be this:
01 | if game.Loaded:Connect() |
06 | if script.Parent.Value < = 0 then |
08 | script.Disabled = true |
10 | elseif script.Parent.Value > 0 then |
12 | script.Parent.Value = script.Parent.Value - 1 |
btw i use --1, --1// as reminders (// means closed so i put it at the end of a function or loop) so i dont lose track of what end goes to what function, its easier to keep track of code, also i space out my code a lot to make it more readable, i suggest these things to speed up your coding and make it easier. i hope this is helpful