|
| 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 |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 22 Dec 2014 08:45 PM |
| Dekkonot y u no give examples for this poor user :/ |
|
|
| Report Abuse |
|
|
dekkonot
|
  |
| Joined: 22 Dec 2010 |
| Total Posts: 6685 |
|
| |
|
|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|