Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

how to fix an if (variable condition) do script?

Asked by 4 years ago

im pretty new to roblox scripting so sorry if it look at little messy but heres my script where i want a brick to set on fire and a bunch of other stuff if clicked too many times, everything works except the actions for when the script gets to a certain variable


CatAnger = 0

function onClick(click) 
    print(CatAnger)
    CatAnger = CatAnger + 1
end

script.Parent.MouseClick:connect(onClick)

while true do
    wait(0.5)
    CatAnger = CatAnger - 1
end

while true do
    if CatAnger > 5 then
        print("DO BEEP BEEP")
    end
    wait(1)
end

function angery()
    workspace.AngerWall.Fire.Enabled = true
    workspace.AngerWall.Smoke.Enabled = true
    workspace.AngerWall.HappytheCat.Transparency = 1
    workspace.AngerWall.angrycat.Transparency = 0
    workspace.AngerWall.AHHH.Sound:Play()

end

while true do

end
if CatAnger < 0 then
    print("1^")
    CatAnger = CatAnger + 1
end

this is the entire script and here are my problems


while true do
    if CatAnger > 5 then
        print("DO BEEP BEEP")
    end
    wait(1)
end

(designed to trigger a function when its over 5)


if CatAnger < 0 then
    print("1^")
    CatAnger = CatAnger + 1
end

(designed to put it back to 0 when it goes under 0)


i've tried to add while true do loops to always be checking if its over but no luck, i'm sure there's a simple answer, plz help C:

0
Was the script parent a ClickDetector? I'll help :D Xapelize 2658 — 4y
0
XD The name is special, a funny game XD Xapelize 2658 — 4y
0
And you can make them into a function instead of while wait() do, a while true do will find the nearest 'end' and fire the code that sandwiched inside the while true do, like line 31 - 33, there sandwiched blank, so line 34 - 37 will not working. And XD I kept laughing when I saw your script XDD Xapelize 2658 — 4y
0
there's too many "while true do" VitroxVox 884 — 4y
0
There is too many while true do. We can only have 1 while true do in each script. TheRealPotatoChips 793 — 4y

1 answer

Log in to vote
0
Answered by
Xapelize 2658 Moderation Voter Community Moderator
4 years ago

You can make them into a function instead of while wait() do, a while true do will find the nearest 'end' and fire the code that sandwiched inside the while true do, like line 31 - 33, there sandwiched blank, so line 34 - 37 will not work.

I just copied the comment to the answer because this is working soooo

If worked just accept lolz I have already upvoted

Ad

Answer this question