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
 

Arguments trouble

Previous Thread :: Next Thread 
ElectoStriking is not online. ElectoStriking
Joined: 10 May 2014
Total Posts: 1547
14 Jan 2016 01:15 PM
For the longest time, there is this thing, this thing that restricts what i can do and its so annoying cause i dont understand them - arguments. I don't understand how people know what the arguments are, that may not make sense lemme give an example:

function OnTouched(touchingPart, touchedPart)
print(touchingPart .. " has touched " .. touchedPart.Name)
end

local Part = Instance.new("Part")
Part.Touched:connect(function(hitPart)
OnTouched(Part, hitPart)
end)

(from the wiki)

I understand how to use events with one arg, the touching part is the part that fired the event, but with two, i just dont get it. How does it work?
Report Abuse
BanTech is not online. BanTech
Joined: 31 Dec 2015
Total Posts: 886
14 Jan 2016 01:19 PM
It's the same concept whether it's one argument or 20. Values passed to the function from the line that called it.

Not sure how you can't extend your knowledge of using one argument, to using multiple?
Report Abuse
ElectoStriking is not online. ElectoStriking
Joined: 10 May 2014
Total Posts: 1547
14 Jan 2016 01:23 PM
wait, im looking for a better example, i get what the two parameters mean in this example sorry
Report Abuse
ElectoStriking is not online. ElectoStriking
Joined: 10 May 2014
Total Posts: 1547
14 Jan 2016 01:29 PM
found one:

PointsService.PointsAwarded:connect(function(userId, userBalanceinUni, userBalance)
-- Show message indicating that a player has gotten points
local message = Instance.new('Message', game.Workspace)
message.Text = "Point awarded to " .. userId .. ". This player now has " .. userBalance .. " points total!"
wait(5)
message:Destroy()
end)

how does the writer know what each arg represents if the don't set them
Report Abuse
Happywalker is not online. Happywalker
Joined: 05 Mar 2010
Total Posts: 3672
14 Jan 2016 01:32 PM
Because they are the function's standard arguments
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
14 Jan 2016 01:34 PM
Because they are already defined and specific to functions.



Touched just passes the part that was touched.
PlayerAdded only passes the player that joined.
PointsAwarded returns four arguments, just read the wiki. http://wiki.roblox.com/index.php?title=API:Class/PointsService/PointsAwarded

That is how you learn scripting and APIs after all, from the wiki.
Report Abuse
ElectoStriking is not online. ElectoStriking
Joined: 10 May 2014
Total Posts: 1547
14 Jan 2016 01:37 PM
@ happy so certain events have built in parameters?
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
14 Jan 2016 01:44 PM
Yeah.
Report Abuse
ElectoStriking is not online. ElectoStriking
Joined: 10 May 2014
Total Posts: 1547
14 Jan 2016 02:00 PM
oh, that clears up the mystery (on my side, the rest of u are just looking at me like 0.o?) thanks guys :)
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