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

How do I make my script print something when a boolvalue changes to true?

local ScreenGui = script.Parent


local Var  = false

ScreenGui.ImageButton1.MouseButton1Down:Connect(function()
	Var = true
end)


ScreenGui.ImageButton1.MouseButton1Up:Connect(function()
	Var = false
end)



if Var == true then
	print('Is True')
end

It wont work even if i put Var == true then

is there any other solution?

1 comment

1

right idea, you're forgetting a while loop

1 answer

local Gui = script.Parent
local Bool = false

Gui.ImageButton1.MouseButton1Down:Connect(function()
	Bool = true
end)

Gui.ImageButton1.MouseButton1Up:Connect(function()
	Bool = false
end)

while true do
	wait()
	if Bool then
	print('babymode')
   end
end

As Fifkee said, it just required a loop.

1 comment

0

honestly thats the closest thing i would say but loops cause lag, especially if it repeats ever 1/60 seconds

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