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

How to make a color changing tool on click?

Asked by 8 years ago

I need only the link to the wiki. the problem is that i need to make a gun and i don't know how to make a event that works like when you click, a code launches. Please explain it or put the wiki.

2 answers

Log in to vote
3
Answered by 8 years ago

Since you have asked for the wiki page, allow me to inform you some good practices for finding what you need on the wiki. The search on the wiki website is a good place to start, but you can also use Google and it generally gives you exactly what you are looking for. In this case, you are asking "How can I find the clicked event of a tool?" The first obvious step is to look at the wiki page for a tool.

http://wiki.roblox.com/index.php?title=API:Class/Tool

Now you've got the page, you just merely need to scroll down and find the "Events" sub-heading which will list all of the instances events. In your case, it would appear you need .Equipped() because this returns a Mouse object (which is what you need for mouse events) Here is the page, which will show you a piece of example code

http://wiki.roblox.com/index.php?title=API:Class/Tool/Equipped

There is also a page on the Mouse object which you can find here

http://wiki.roblox.com/index.php?title=API:Class/Mouse

Again, you are wanting to find the event of a player clicking the left mouse, so you need Button1Down

http://wiki.roblox.com/index.php?title=API:Class/Mouse/Button1Down

Above is a piece of example code which, if you paste directly into a clean script, will print "Button1Down" every time you press the left mouse button. You must ensure that this is a LocalScript otherwise, you will not be able to get the players input.

0
Actually, i used the search ball million times, but nothing popped out. bartekrabit 38 — 8y
Ad
Log in to vote
-2
Answered by 8 years ago
brick = script.Parent

brick.onClicked:connect(function())
brick.BrickColor = brick.BrickColor.new(random)
end
0
Not only is this code wrong, It's not what the user has asked for. Nauseating 125 — 8y
0
I know what is an onClicked function with a part. I wanted to know about an another event. bartekrabit 38 — 8y

Answer this question