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: What's the difference between

Previous Thread :: Next Thread 
DurstAuric is not online. DurstAuric
Joined: 12 May 2009
Total Posts: 8066
22 Dec 2014 08:40 PM
[] and ()?
Example.

part.Touched:connect(function(player)
if(player.Parent:findFirstChild("Humanoid")) then
if game:GetService("GamePassService"):PlayerHasPass(game.Players[player.Parent.Name], god) then
print("'ayyy lmao, ur jebus.")
else
player.Parent.Humanoid.Health = 0
end
end
end)

I'm clueless how the [] works in that script. Someone tell me?


No more #MerelyIlluminati, we all know it's #DurstIlluminati. (R$53,091) (RAP: 618,394)
Report Abuse
DurstAuric is not online. DurstAuric
Joined: 12 May 2009
Total Posts: 8066
22 Dec 2014 08:42 PM
I mean, I know how to use (), but []? Nop. I know how {} works..


No more #MerelyIlluminati, we all know it's #DurstIlluminati. (R$53,092) (RAP: 618,394)
Report Abuse
StealthKing95 is not online. StealthKing95
Joined: 13 Dec 2008
Total Posts: 4263
22 Dec 2014 08:43 PM
() are used for mathematical order of operations, or when calling functions.

e.g.

function lel(k)
print(k)
end

lel("lel")

[] are used to index tables with.

e.g.

lel = {"bb", "aa", "cc"}
print(lel[2]) --2 means the second entry in the table, which is "aa"
>aa

Another example of []:


plrs = game.Players:GetPlayers() --returns a table of players(each have a numerical key, and userdata value

print(plrs[#plrs].Name)
Report Abuse
dekkonot is not online. dekkonot
Joined: 22 Dec 2010
Total Posts: 6685
22 Dec 2014 08:44 PM
Square brackets, []s, are used to access a specific object within a table or userdata.

Parenthesis, ()s, are used to hold the arguments for functions and methods.
Report Abuse
StealthKing95 is not online. StealthKing95
Joined: 13 Dec 2008
Total Posts: 4263
22 Dec 2014 08:45 PM
Dekkonot y u no give examples for this poor user :/
Report Abuse
dekkonot is not online. dekkonot
Joined: 22 Dec 2010
Total Posts: 6685
22 Dec 2014 08:48 PM
Cuz.
Report Abuse
DurstAuric is not online. DurstAuric
Joined: 12 May 2009
Total Posts: 8066
22 Dec 2014 08:51 PM
So, is this right?

placeId = 0
part = script.Parent
gamePassId = 0

part.Touched:connect(function(player)
if(player.Parent:findFirstChild("Humanoid")) then
if game:GetService("GamePassService"):PlayerHasPass(game.Players[player.Parent.Name], gamePassId) then
game:GetService("TeleportService"):TeleportToSpawnByName(placeId, "SpawnLocation",(game.Players[player.Parent.Name]))
else
print("Access Denied. Please purchase the Game Pass.")
end
end
end)


No more #MerelyIlluminati, we all know it's #DurstIlluminati. (R$53,231) (RAP: 618,394)
Report Abuse
dekkonot is not online. dekkonot
Joined: 22 Dec 2010
Total Posts: 6685
22 Dec 2014 08:53 PM
Okay, so I'd seriously come out against you using square brackets to access objects within an instance (try using FindFirstChild instead) but yes, that should in theory work.

Off topic, though:


if(player.Parent:findFirstChild("Humanoid")) then
if game:GetService("GamePassService"):PlayerHasPass(game.Players[player.Parent.Name], gamePassId) then

y u do dis?
Report Abuse
DurstAuric is not online. DurstAuric
Joined: 12 May 2009
Total Posts: 8066
22 Dec 2014 08:54 PM
So, that script should teleport the player to the place, if they own the pass?


No more #MerelyIlluminati, we all know it's #DurstIlluminati. (R$53,377) (RAP: 618,394)
Report Abuse
StealthKing95 is not online. StealthKing95
Joined: 13 Dec 2008
Total Posts: 4263
22 Dec 2014 08:55 PM
"I'd seriously come out against you using square brackets to access objects within an instance (try using FindFirstChild instead)"

I was gonna write a long objection to that but then I realized 99% of the people here asking help don't care about software development, they just wish to have an idea of theirs work without errors
Report Abuse
dekkonot is not online. dekkonot
Joined: 22 Dec 2010
Total Posts: 6685
22 Dec 2014 08:55 PM
Assuming the object that touched the part it's in wasn't a hat, tool, or other block, yes.
Report Abuse
DurstAuric is not online. DurstAuric
Joined: 12 May 2009
Total Posts: 8066
22 Dec 2014 08:56 PM
More or less. But, will it work as scripted..?


No more #MerelyIlluminati, we all know it's #DurstIlluminati. (R$53,377) (RAP: 618,394)
Report Abuse
dekkonot is not online. dekkonot
Joined: 22 Dec 2010
Total Posts: 6685
22 Dec 2014 08:57 PM
Yes, again, if we assume that no one's hat or tool is going to touch the block AND that no block outside of someone's character touches it.
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