generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: how do you make a script activated by a button?

Previous Thread :: Next Thread 
roblox0robot0 is not online. roblox0robot0
Joined: 31 Mar 2012
Total Posts: 21
11 Jul 2012 02:37 PM
i was wondering how you write a script that is activated by a button
Report Abuse
FreeGamesROBLOX is not online. FreeGamesROBLOX
Joined: 15 Jun 2011
Total Posts: 6622
11 Jul 2012 02:38 PM
I'll give you a hint, onClicked()
Report Abuse
WhiteRain is not online. 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 is not online. 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 is not online. 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 is not online. human
Joined: 06 May 2007
Total Posts: 2765
11 Jul 2012 02:50 PM
cause I learned that way D:
Report Abuse
WhiteRain is not online. 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
roblox0robot0 is not online. roblox0robot0
Joined: 31 Mar 2012
Total Posts: 21
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
builderman1171 is not online. builderman1171
Joined: 27 Mar 2010
Total Posts: 1595
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
builderman1171 is not online. builderman1171
Joined: 27 Mar 2010
Total Posts: 1595
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 is not online. 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
roblox0robot0 is not online. roblox0robot0
Joined: 31 Mar 2012
Total Posts: 21
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
roblox0robot0 is not online. roblox0robot0
Joined: 31 Mar 2012
Total Posts: 21
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
thezombiegirl111 is not online. thezombiegirl111
Joined: 23 May 2012
Total Posts: 20
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
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
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
roblox0robot0 is not online. roblox0robot0
Joined: 31 Mar 2012
Total Posts: 21
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
epicfail22 is not online. epicfail22
Joined: 25 Sep 2009
Total Posts: 3739
17 Jul 2012 01:10 PM
Is the 'button' a GUI or a Part?
Report Abuse
roblox0robot0 is not online. roblox0robot0
Joined: 31 Mar 2012
Total Posts: 21
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 is not online. 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
epicfail22 is not online. epicfail22
Joined: 25 Sep 2009
Total Posts: 3739
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
roblox0robot0 is not online. roblox0robot0
Joined: 31 Mar 2012
Total Posts: 21
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
roblox0robot0 is not online. roblox0robot0
Joined: 31 Mar 2012
Total Posts: 21
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
Abstractrobocux is not online. Abstractrobocux
Joined: 20 Jun 2012
Total Posts: 19
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 is not online. 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
roblox0robot0 is not online. roblox0robot0
Joined: 31 Mar 2012
Total Posts: 21
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image