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 » Scripters
Home Search
 

Re: How do I make up my own functions?

Previous Thread :: Next Thread 
MilkyWay01 is not online. MilkyWay01
Joined: 22 Feb 2010
Total Posts: 1049
29 Aug 2015 11:25 PM
Like at the end of one script tell another script to start running
Report Abuse
AdamHighDefinition is not online. AdamHighDefinition
Joined: 09 Aug 2015
Total Posts: 628
29 Aug 2015 11:28 PM
function mycustomfunction()
-- script
end



script.Parent.Touched:connect(function()
mycustomfunction()
end)
Report Abuse
pinballboy7 is not online. pinballboy7
Joined: 12 Mar 2009
Total Posts: 1485
29 Aug 2015 11:28 PM
function MakePoop(Food)
for i,v in pairs(Stomach:GetChildren()) do
v:Digest()
v:Poop()
end
end
Report Abuse
MilkyWay01 is not online. MilkyWay01
Joined: 22 Feb 2010
Total Posts: 1049
29 Aug 2015 11:31 PM
Can someone explain it more clearly? I don't really get what the first two people are saying. To be clear, I want one script to say something like "Start Test Function" an another script to be like "function on Test Started"
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
29 Aug 2015 11:32 PM
'Like at the end of one script tell another script to start running'
Just do otherScript.Disabled = false?
Report Abuse
pinballboy7 is not online. pinballboy7
Joined: 12 Mar 2009
Total Posts: 1485
29 Aug 2015 11:34 PM
to create a function:
function YourFunction(Arguments)

end

to call a function:
YourFunction(Arguments)

Arguments are information given to the function when the function is called. For instance:

function PrintName(Name)
print(Name)
end

PrintName(game.Workspace.Swag)

results in:

"Swag"

Report Abuse
pinballboy7 is not online. pinballboy7
Joined: 12 Mar 2009
Total Posts: 1485
29 Aug 2015 11:35 PM
Read the Roblox wiki's page on functions. http://wiki.roblox.com/index.php?title=Function
Report Abuse
AdamHighDefinition is not online. AdamHighDefinition
Joined: 09 Aug 2015
Total Posts: 628
29 Aug 2015 11:36 PM
Alright.

function YourFunctionName() -- This is the function, inorder for it to do whatever -- code you have inside it it needs to be fired.
game.Workspace.Part.BrickColor = BrickColor.new("Bright red")-- Whatever you want --to put in it
end--end the function


Now when you want to change the parts color to red, you need to fire the function,
its done like this


YourFunctionName()-- Thats it!
if you wanted to fire it when a part is touched you would do

game.Workspace.Part.Touched:connect(YourFunctionName)
Report Abuse
MilkyWay01 is not online. MilkyWay01
Joined: 22 Feb 2010
Total Posts: 1049
29 Aug 2015 11:38 PM
I kinda get it, but I still can't get it to work

Script 1:

.....(other stuff)....
OddChange(Change)
....(other stuff)....


Script 2:

function OddChange (Change)
stuff
end
Report Abuse
NotAshley is not online. NotAshley
Joined: 16 Jan 2014
Total Posts: 14257
30 Aug 2015 12:10 AM
Functions can't communicate between scripts. You'll want to look into RemoteFunctions, but only after you've gained a solid understanding of the basics of RBX.Lua.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
30 Aug 2015 12:40 AM
Well, they can but it's not ideal.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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