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

How can I get my StartGUI to have a working button?

Asked by 9 years ago

Alright so I made a brick to become a conveyer. I wanted it to be where when you sat down on a seat the GUI for the convayer controls would appear. I made a text button so when you click it would start and the text color would become green. When you click it again it would be red. I'm not sure about how to make it change colors but what is the command to put in our script to say "When the button is clicked, the conveyer will start and the color will turn green?"

ding = game.Lighting.CheckIn.TextButton

function conveyer()
    if clicked = then  --MY TROUBLE

end

Thanks guys. Bad scripter here :3

1 answer

Log in to vote
0
Answered by 9 years ago

To achieve this, we need to get some basic understandings down. Let's start with an if statement.


Let's take a look at if's.

An example of an if statement would be:

x = 1

if x == 1 then
    print("This would print")
else
    print("This wouldn't, since x is 1.")
end

This if statement would have the output of:

This would print


Let's take a look at the same script, but play with it some more.

x = 2 -- Change it, and see what happens.

if x == 1 then
    print("This would print")
else
    print("This wouldn't, since x is 1.")
end

Now our output would be:

This wouldn't, since x is 1


Now that we understand if's, let's understand the next principle, MouseButton1Down.

All Gui TextButtons have this event. It fires whenever the left mouse button is clicked down.

script.Parent.MouseButton1Down:connect(function (onClicked)
    -- Code goes here.
end)

I'm not going to provide an actual script in an attempt to allow you to learn. Be sure to check the wiki and search for "TextButton" so you can see examples of changing colors.

0
THANK YOU SO MUCH!!! VirtualFlying 55 — 9y
Ad

Answer this question