|
| 24 May 2013 06:19 PM |
| I have never got to understand what this meant. Could somebody teach me just what this is? it has been mocking me for a long time now and I wish to know, thanks to anybody who is helpful enough to tell me. |
|
|
| Report Abuse |
|
|
|
| 24 May 2013 06:21 PM |
| It is used in almost every script. |
|
|
| Report Abuse |
|
|
|
| 24 May 2013 06:22 PM |
| pcall has also been confusing me. |
|
|
| Report Abuse |
|
|
NVianney
|
  |
| Joined: 24 Mar 2012 |
| Total Posts: 173 |
|
|
| 24 May 2013 06:23 PM |
local TableValue = {"a", "b", "c", "d"}
for i=1, #TableValue do print(TableValue[i]) end
Is the same as:
for i, v in pairs(TableValue) do print(v) end
Both of them will have the same output. |
|
|
| Report Abuse |
|
|
|
| 24 May 2013 06:23 PM |
| Didn't understand either one of them. |
|
|
| Report Abuse |
|
|
|
| 24 May 2013 06:24 PM |
I just need to know what for means.
I think I know tables.
TableG{}
TableG[1] = "ASDQ, ASDF, ASDE" |
|
|
| Report Abuse |
|
|
|
| 24 May 2013 06:25 PM |
Nevermind.
These 2 have been puzzling me ever since I started scripting. |
|
|
| Report Abuse |
|
|
NVianney
|
  |
| Joined: 24 Mar 2012 |
| Total Posts: 173 |
|
|
| 24 May 2013 06:25 PM |
Have you have heard of Java? If you do, this will be similar: try{ System.out.println(sdf); //This will be an error catch(Exception e){ }
If you didn't, then here is an example:
function a() print(abc) end a()
If you do that, you will get an error, and the script will stop. But if you do this: pcall(a()) then it will also cause an error, but the script will continue. |
|
|
| Report Abuse |
|
|
|
| 24 May 2013 06:26 PM |
[Started at 6:20 PST] I'll try and brake it down and tell you the most basic use I know of.
So basically, you can use "in pairs" to get a bunch of objects and be able to edit them.
for _,v in pairs("game.Workspace.Model:GetChildren()) do
It took me a while to finally comprehend how it works, but basically, v is this: GetChildren()
and _ is this: game.Workspace.Model
For example. if you did
for _,v in pairs("game.Workspace:GetChildren()) do print(v.Name) end
that would print the name of every object in Workspace, but no deeper.
You can use this to do anything to a large amount of bricks without having to type out the name of every one.
If you have any other questions, just ask. |
|
|
| Report Abuse |
|
|
|
| 24 May 2013 06:31 PM |
| im just going to stay with my normal old way... i feel im making too big of a step here |
|
|
| Report Abuse |
|
|
|
| 24 May 2013 06:34 PM |
wait(60) for _, v in pairs(game.Workspace:GetChildren()) do if (v:IsA("Hat")) then v:Destroy() end end
--[[ I was just playing with it and I found a hat clean script. ]]-- -- Tell me if this is correct. |
|
|
| Report Abuse |
|
|
NVianney
|
  |
| Joined: 24 Mar 2012 |
| Total Posts: 173 |
|
|
| 24 May 2013 06:37 PM |
It's correct. BUT if you want to check in models, simply write: function check(parent) for _, v in pairs(parent) do if (v:IsA("Hat")) then v:Destroy() elseif (v:IsA("Model")) then check(v) end end end check(game.Workspace) |
|
|
| Report Abuse |
|
|
NVianney
|
  |
| Joined: 24 Mar 2012 |
| Total Posts: 173 |
|
|
| 24 May 2013 06:37 PM |
Oops. Fixed code: function check(parent) for _, v in pairs(parent:GetChildren()) do if (v:IsA("Hat")) then v:Destroy() elseif (v:IsA("Model")) then check(v) end end end check(game.Workspace) |
|
|
| Report Abuse |
|
|
|
| 24 May 2013 06:39 PM |
| I don't want to get of everybodys hat, just spare hats on the ground. |
|
|
| Report Abuse |
|
|
|
| 24 May 2013 06:40 PM |
while true do
wait(60) for _, v in pairs(game.Workspace:GetChildren()) do if (v:IsA("Hat")) then v:Destroy() end end
That correct? |
|
|
| Report Abuse |
|
|
NVianney
|
  |
| Joined: 24 Mar 2012 |
| Total Posts: 173 |
|
|
| 24 May 2013 06:42 PM |
| Yes, but you forgot to add the "end" statement to close the "while" loop. Overall, it's correct, but the one I mentioned above. |
|
|
| Report Abuse |
|
|
|
| 24 May 2013 06:42 PM |
--[[ Hat Destroyer V1.0 ]]--
--[[ Created by EpicTinyroblox099 with assistance from the Scripting Helpers SubForum --]]
while true do
wait(60) for _, v in pairs(game.Workspace:GetChildren()) do if (v:IsA("Hat")) then v:Destroy()
end
end
So, v is like.... GetChildren from Workspace
I just don't get the use of parinthesis though. |
|
|
| Report Abuse |
|
|
|
| 24 May 2013 06:43 PM |
--[[ Hat Destroyer V1.0 ]]--
--[[ Created by EpicTinyroblox099 with assistance from the Scripting Helpers SubForum --]]
while true do end
wait(60) for _, v in pairs(game.Workspace:GetChildren()) do if (v:IsA("Hat")) then v:Destroy()
end
end
|
|
|
| Report Abuse |
|
|
NVianney
|
  |
| Joined: 24 Mar 2012 |
| Total Posts: 173 |
|
|
| 24 May 2013 06:44 PM |
| Add an "end" statement to close the while loop. FYI, v can be renamed, because it is a variable; including the "_" in for _, |
|
|
| Report Abuse |
|
|
|
| 24 May 2013 06:50 PM |
--[[ Hat Destroyer V1.0 ]]--
--[[ Created by EpicTinyroblox099 with assistance from the Scripting Helpers SubForum --]]
while true do wait(60) for _, v in pairs(game.Workspace:GetChildren()) do if (v:IsA("Hat")) then v:Destroy() end end end
|
|
|
| Report Abuse |
|
|
|
| 24 May 2013 06:54 PM |
while true do wait(60) for _, v in pairs(game.Workspace:GetChildren()) do if (v:IsA("Hat, Tool")) then v:Destroy() end end end
Would this work? |
|
|
| Report Abuse |
|
|
NVianney
|
  |
| Joined: 24 Mar 2012 |
| Total Posts: 173 |
|
|
| 24 May 2013 06:54 PM |
It's correct. BUT if you want to immediately remove hats when they show up, simply write: Workspace.ChildAdded:connect(function(child) if (child:IsA("Hat")) then child:Destroy() end end
|
|
|
| Report Abuse |
|
|
|
| 24 May 2013 06:58 PM |
while true do wait(60) q = Instance.new("Hint", workspace) q.Text = "Cleaning ..." wait(5) q:Destroy() end
wait(60) for _, v in pairs(game.Workspace:GetChildren()) do if (v:IsA("Hat")) then v:Destroy() end end end
will this work |
|
|
| Report Abuse |
|
|
NVianney
|
  |
| Joined: 24 Mar 2012 |
| Total Posts: 173 |
|
|
| 24 May 2013 07:01 PM |
| It will say: "Cleaning...", after 5 seconds, the hint will be removed. After 1 minute, it will remove hats. |
|
|
| Report Abuse |
|
|