Ad
Log in to vote
0

How to make it so that you click a button and it responds to the click?

Asked by 12 days ago

Hello, I am a very new Roblox scripter and I would like to know how to do this. I've learnt basic things like variables, functions, and arithmetic. If you add the GUI button icon what do you do from there?

0
For parts you can use a ClickDetector, or for a screenGUI use a TextButton or an ImageButton. DinozCreates 1001 — 12d
0
Thank you! projectzrgosbrother 0 — 12d

1 answer

Log in to vote
0
Answered by 12 days ago

Hello, I am also a new roblox lua scripter. Here is something you can start off doing if you want to mess with "Guis" that do something when a button is clicked. The lines of code you see below is just some simple lines of code i've learnt in a day or two.

-- Made by Nitrolux200, Instructions below.
-- In "StarterGui" add a "ScreenGui" and name it however you like.
-- Insert an "ImageLabel" inside the "ScreenGui", put the image in the "ImageLabel" and make visible to false. 
-- Insert a "TextButton" and inside the "TextButton" add a "LocalScript" inside.
-- Go in the local script and copy and paste the lines of code below if you want to.

local image = script.Parent.Parent.ImageLabel 
local button = script.Parent
visible = false

script.Parent.MouseButton1Click:Connect(function()
    if visible == false then
        visible = true
        image.Visible = true

    else
        visible = false
        image.Visible = false
    end
end)

button.MouseEnter:Connect(function()
    if image.Visible == false then
        button.Text = "Open Image"

    else
        button.Text = "Close Image"
    end
end)

button.MouseLeave:Connect(function()
    if image.Visible == true then
        button.Text = "Close Image"

    else
        button.Text = "Open Image"
    end
end)

-- Script works just fine, if for some reason it doesn't work contact me "ASAP" !

P.S) if you want to accpet this answer as the "my question answered" since I gave you an example i'd be very appreciated :)

0
Thank you projectzrgosbrother 0 — 11d
Ad

Answer this question