Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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:

5 comments

0

Was the script parent a ClickDetector? I'll help :D

0

XD The name is special, a funny game XD

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

0

there's too many "while true do"

0

There is too many while true do. We can only have 1 while true do in each script.

1 answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.