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

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

Asked by 4 years ago
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
right idea, you're forgetting a while loop Fifkee 2017 — 4y

1 answer

Log in to vote
2
Answered by 4 years ago
Edited 4 years ago
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.

0
honestly thats the closest thing i would say but loops cause lag, especially if it repeats ever 1/60 seconds SoftlockedUnderZero 668 — 4y
Ad

Answer this question