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

How to make a color changing tool on click?

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

✓ Accepted answer

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.

1 comment

0

Actually, i used the search ball million times, but nothing popped out.

brick = script.Parent

brick.onClicked:connect(function())
brick.BrickColor = brick.BrickColor.new(random)
end

2 comments

0

Not only is this code wrong, It's not what the user has asked for.

0

I know what is an onClicked function with a part. I wanted to know about an another event.

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