Gnago
|
  |
| Joined: 28 Jan 2014 |
| Total Posts: 372 |
|
|
| 01 May 2015 07:02 PM |
I'm learning Lua through getting free scripts off free models and editing them to do something slightly different, and I was wondering if the "i" in this script is just a variable, or if its a concept... Also, if possible I would appreciate if someone could also explain what '#' means, thanks!
function Weld(x,y) local W = Instance.new("Weld") W.Part0 = x W.Part1 = y local CJ = CFrame.new(x.Position) local C0 = x.CFrame:inverse()*CJ local C1 = y.CFrame:inverse()*CJ W.C0 = C0 W.C1 = C1 W.Parent = x end
local D = false function onTouch(hit) if D == false then D = true if hit.Parent:findFirstChild("Humanoid") ~= nil then if hit.Parent:findFirstChild("Humanoid").Health > 0 then local P = hit.Parent:GetChildren() local M = Instance.new("Model") -- This is the Clone local H = Instance.new("Humanoid") M.Parent = game.Workspace M.Name = hit.Parent.Name if hit.Parent:findFirstChild("Pants") ~= nil then hit.Parent.Pants.Parent = M end if hit.Parent:findFirstChild("Shirt") ~= nil then hit.Parent.Shirt.Parent = M end for i=1, #P do if P[i].className == "Part" then local C = P[i]:clone() C.Parent = M C.Locked = false C.CanCollide = true P[i]:remove() end if P[i].className == "Hat" then P[i].Parent = M end end M:MoveTo(Vector3.new(198.84, -24.6, -269.57)) M:MakeJoints() local P = M:GetChildren() for i=1, #P do if P[i].Name ~= "Torso" and P[i].Name ~= "Pants" and P[i].Name ~= "Shirt" and P[i].className ~= "Hat" then Weld(M.Torso,P[i]) end if P[i].className == "Hat" then Weld(M.Torso,P[i].Handle) end end H.Parent = M end end wait(2) D = false end end
script.Parent.Touched:connect(onTouch) |
|
|
| Report Abuse |
|
|
Gnago
|
  |
| Joined: 28 Jan 2014 |
| Total Posts: 372 |
|
|
| 01 May 2015 07:03 PM |
| BTW this is a cloning script, incase you couldn't find out and needed to know... |
|
|
| Report Abuse |
|
|
Gnago
|
  |
| Joined: 28 Jan 2014 |
| Total Posts: 372 |
|
| |
|
Intern33t
|
  |
| Joined: 19 Nov 2010 |
| Total Posts: 1530 |
|
|
| 02 May 2015 08:53 AM |
local tab = {342, "potato", math.pi} local w = #tab
print(w)
Will print
3
because # returns the length of a table.
When he uses P[i], he targets the i'th element (i = 3, 3th element, i= = 2, 2nd element) of the array P |
|
|
| Report Abuse |
|
|