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

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

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?

2 comments

0

For parts you can use a ClickDetector, or for a screenGUI use a TextButton or an ImageButton.

0

Thank you!

1 answer

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 :)

1 comment

0

Thank you

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