#i want to change background color while pressed

29 messages · Page 1 of 1 (latest)

true kite
#

i want to change background color while pressed and how to change background color to default while pressed again

normal mortar
#

I think there are functions

#

That active when button is pressed and hold

#

And when there are released

#

U can use that

wintry magnet
#
button.MouseButton1Down:Connect(function()
  background.BrickColor = BrickColor.red
end
#

its gui

last nacelleBOT
#

studio** You are now Level 1! **studio

true kite
#

its a gui

true kite
normal mortar
#

It prob would be mouse something

last nacelleBOT
#

studio** You are now Level 5! **studio

normal mortar
#

U can type .mouse and hover each one and it will explain

#

What it does

radiant crypt
true kite
radiant crypt
#

Frame or button?

true kite
#

button

radiant crypt
#

button.MouseButton1Click:Connect(function()
button.BackgroundColor3 = Color.new(1,1,1)
end

dawn lark
# true kite yep

use a toggle to detect when its on and off

local colortoggle = false

urbutton.MouseButton1Down:Connect(function()
if not colortoggle then
colortoggle = true
frame.BackgroundColor3 = Color3.fromRGB(0,0,0) -- the color u want when its on
else
colortoggle = false
frame.BackgroundColor3 = Color3.fromRGB(0,0,0) -- the color u want when its off
end)

#

dont make a thread like this all the time tho, i recommend using google before anything

#

theirs probably plenty of resources telling u how to achieve this if u search it up 👍

true kite
#

and how its when i pressed the color change?

#

not click

dawn lark
#

huh

wispy onyx
#
-- Define variables
local button = script.Parent.Button
local originalColor = button.BackgroundColor3
local newColor = Color3.fromRGB(255, 0, 0) -- Replace with desired new color
local changeTime = 3 -- Replace with desired change time in seconds

-- Function to change the color of the button
local function changeButtonColor()
    button.BackgroundColor3 = newColor
    wait(changeTime)
    button.BackgroundColor3 = originalColor
end

-- Connect the function to the button's "Activated" event
button.Activated:Connect(changeButtonColor)

-- made by AimbotR_bro1, if you would like to contribute to a donation dm on discord, daddy m#8718