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

How do I make my ImageButton change back after a certain waiting time?

Asked by
iVmk3 -143
4 years ago
Edited 4 years ago
local button = script.Parent
local toggled = false

local function onButtonActivated()
    if toggled == false then
        button.Image = "rbxgameasset://Images/ImageButtonActivated"
        toggled = true
    else        
        button.Image = "rbxgameasset://Images/ImageButtonNormal"
        toggled = false
    end
end

button.Activated:Connect(onButtonActivated)

This is my script for a click changing my ImageButton to something else. I need to know how to make it change back to ImageButtonNormal after a certain waiting time.

0
Just use a wait() system call MusicalDisplay 173 — 4y
0
Where would I put that into my script? Also, do I put "system call" into the line? iVmk3 -143 — 4y

1 answer

Log in to vote
1
Answered by
Ziffixture 6913 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.
local Button = script.Parent

local ImageActivated = "rbxgameasset://Images/ImageButtonActivated"
local ImageNormal = "rbxgameasset://Images/ImageButtonNormal"

local function OnButtonActivated()
    Button.Image = ImageActivated
    delay(3, function()
         Button.Image = ImageNormal 
    end)
end

Button.Activated:Connect(onButtonActivated)
0
This works! Thank you so much! iVmk3 -143 — 4y
Ad

Answer this question