|
| 11 Jul 2012 02:37 PM |
| i was wondering how you write a script that is activated by a button |
|
|
| Report Abuse |
|
|
|
| 11 Jul 2012 02:38 PM |
| I'll give you a hint, onClicked() |
|
|
| Report Abuse |
|
|
WhiteRain
|
  |
| Joined: 24 Apr 2010 |
| Total Posts: 2723 |
|
|
| 11 Jul 2012 02:43 PM |
| ^ lolno. The Function name can be anything it just depends on the event you want. Is this for a Gui button? If so you can use .MouseButton1Down or even .MouseButton2Down. |
|
|
| Report Abuse |
|
|
human
|
  |
| Joined: 06 May 2007 |
| Total Posts: 2765 |
|
|
| 11 Jul 2012 02:47 PM |
for a gui
function humanlikespie() --code script.Parent.MouseButton1Down:connect(humanlikespie) |
|
|
| Report Abuse |
|
|
WhiteRain
|
  |
| Joined: 24 Apr 2010 |
| Total Posts: 2723 |
|
|
| 11 Jul 2012 02:49 PM |
Y U NO USE ANONYMOUS FUNCTIONS??
script.Parent.MouseButton1Down:connect(function() --[[code]]-- end) |
|
|
| Report Abuse |
|
|
human
|
  |
| Joined: 06 May 2007 |
| Total Posts: 2765 |
|
|
| 11 Jul 2012 02:50 PM |
| cause I learned that way D: |
|
|
| Report Abuse |
|
|
WhiteRain
|
  |
| Joined: 24 Apr 2010 |
| Total Posts: 2723 |
|
|
| 11 Jul 2012 02:51 PM |
| Try using anonymous functions as they run faster and are better. And because they are cooler. :) |
|
|
| Report Abuse |
|
|
|
| 16 Jul 2012 09:36 PM |
i have absolutely no idea what u guys are saying i know like 1% of scripting :b
the only things i can really do i something like game.Lighting.model: clone () .Parent = game.Workspace
so i can pretty much only make map changers and disaster scripts :l |
|
|
| Report Abuse |
|
|
|
| 16 Jul 2012 09:42 PM |
Click Detector Method:
script.Parent.ClickDetector.MouseClick:connect(function(Clicker) --Clicker is who clicked... end)
GUI Detector Method:
script.Parent.MouseButton1Down:connect(function() --stuff end) --TehChikenHater ლ(ಠ_ಠლ) |
|
|
| Report Abuse |
|
|
|
| 16 Jul 2012 09:43 PM |
@WhiteRain
Anonymous functions do not run faster. And sometimes having named functions are useful, example:
function Print2(Text) print(Text) end
script.Parent.Touched:connect(function() Print2("Hi) end)
--TehChikenHater ლ(ಠ_ಠლ) |
|
|
| Report Abuse |
|
|
lucas668
|
  |
| Joined: 18 Jun 2008 |
| Total Posts: 6183 |
|
|
| 16 Jul 2012 09:47 PM |
| In large scripts where you would want multiple chunks of code have access to do a certain function, it's near-mandatory to have defined functions in place of anonymous functions. |
|
|
| Report Abuse |
|
|
|
| 16 Jul 2012 10:13 PM |
i guess i could just look at scripts that are already written its how i learned the other stuff i said
also i didnt realize how many people reply in like 20 minutes |
|
|
| Report Abuse |
|
|
|
| 16 Jul 2012 10:14 PM |
| ok maybe it was an hour or 2 but i'm surprised about the number of people tht reply anyway |
|
|
| Report Abuse |
|
|
|
| 16 Jul 2012 10:46 PM |
| i know how to make that! its easy! once you have the script open view then open basic objects and just.. OK OK youl see the object you need. it will say somthing >:3 then click it and drag it to your script. well thats how i did it! |
|
|
| Report Abuse |
|
|
|
| 16 Jul 2012 10:49 PM |
> i know how to make that! its easy! **once you have the script**...
Well yeah, that's the part he's having trouble with.
† KMXD † |
|
|
| Report Abuse |
|
|
|
| 17 Jul 2012 12:48 PM |
@ zombie girl yeah i dont have the script for it even if i did your not explaining it correctly or SOMETHING.
but the script i'm trying to write is something like you click on a button and a teleporter apears somewhere or something |
|
|
| Report Abuse |
|
|
|
| 17 Jul 2012 01:10 PM |
| Is the 'button' a GUI or a Part? |
|
|
| Report Abuse |
|
|
|
| 19 Jul 2012 12:43 AM |
| above* it is not a GUI mostly cause i know nothing about GUI's but that's not important...anyway like i said its a script where u click a button and something appears |
|
|
| Report Abuse |
|
|
Shoqwave
|
  |
| Joined: 13 May 2012 |
| Total Posts: 215 |
|
|
| 19 Jul 2012 12:46 AM |
> "it is not a GUI . . . but that's not important"
It changes EVERYTHING in a script. |
|
|
| Report Abuse |
|
|
|
| 19 Jul 2012 09:30 AM |
If it's a part then...
local part = script.Parent if not part:findFirstChild("ClickDetector") then cd = Instance.new("ClickDetector",part) end cd.MouseClick:connect(function(player) --[[code]]-- end)
|
|
|
| Report Abuse |
|
|
|
| 19 Jul 2012 01:02 PM |
@shoqwave i meant the fact i dont know anything about GUI's is not important do you really think i'm stupid enough to think that whethor its a gui or part doesnt matter?
@epicfail so how do i put this into a script to make something happen? |
|
|
| Report Abuse |
|
|
|
| 19 Jul 2012 01:40 PM |
| wait u mean like put an "if" before what u said and a "then" before the thing i want to be done? |
|
|
| Report Abuse |
|
|
|
| 19 Jul 2012 02:17 PM |
You could put a value that's activated when the buttons clicked, and then the script checks the value. Simple. ^_^ -=Robo=- |
|
|
| Report Abuse |
|
|
Shoqwave
|
  |
| Joined: 13 May 2012 |
| Total Posts: 215 |
|
|
| 19 Jul 2012 04:34 PM |
> ". . . do you really think i'm stupid enough . . ."
Well, when you put it that way... yes.
No offense, of course. Everyone is stupid in their own, unique, way. |
|
|
| Report Abuse |
|
|
|
| 19 Jul 2012 11:59 PM |
| @shoqwave i guess your right everyone is pretty stupid n their own way so let me rephrase that: do you really think i know so little about scripting? well i do know little but that is beside the point |
|
|
| Report Abuse |
|
|