Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I fix these warning? (Unknown Global and Indentation)

Here's part of the code:

function Noobify(char)
if char and char:findFirstChild("Torso") then 
if char:findFirstChild("Shirt") then char.Shirt.Parent = char.Torso end
if char:findFirstChild("Pants") then char.Pants.Parent = char.Torso end
for a, sc in pairs(char:children()) do if sc.Name == "ify" then sc:Destroy() end end
local cl = Instance.new("StringValue", char) cl.Name = "ify" cl.Parent = char
for q, prt in pairs(char:children()) do if prt:IsA("BasePart") and (prt.Name ~= "Head" or not prt.Parent:findFirstChild("NameTag", true)) then 
prt.Transparency = 0 prt.Reflectance = 0 prt.BrickColor = BrickColor.new("Bright yellow")
if prt.Name:find("Leg") then prt.BrickColor = BrickColor.new("Br. yellowish green") elseif prt.Name == "Torso" then prt.BrickColor = BrickColor.new("Bright blue") end
local tconn = prt.Touched:connect(function(hit) if hit and hit.Parent and game.Players:findFirstChild(hit.Parent.Name) and cl.Parent == char then Noobify(hit.Parent) elseif cl.Parent ~= char then tconn.disconnect() end end)
cl.Changed:connect(function() if cl.Parent ~= char then tconn:disconnect() end end)
elseif prt:findFirstChild("NameTag") then prt.Head.Transparency = 0 prt.Head.Reflectance = 0 prt.Head.BrickColor = BrickColor.new("Bright yellow")
end end
end
end

Code: prt:findFirstChild("NameTag")

Gives Warning: Statement spans multiple lines; use indentation to silence. (Tried indenting and nothing works)

========================

Code: tconn.disconnect()

Gives Warning: Unknown global 'tconn'

How do I fix and get rid of these warning?

5 comments

0

Use code blocks

0

You are using 'tconn' within your connect function before it has been created.

0

I fixed "tconn" with "local tconn = Instance.new("StringValue", char) local Name = "tconn" local Parent = char" I just need help with my second issue with the indentation.

1

Your code makes me cringe .-. read this article: https://scriptinghelpers.org/blog/clean-and-tidy

1

It's not my code I'm just fixing warnings on it. I don't want any warning or errors in the scripts that will be running. I like to have a clean and tidy error free environment. Pretty sure everyone does.

1 answer

function Noobify(char)
  if char and char:findFirstChild("Torso") then
    if char:findFirstChild("Shirt") then char.Shirt.Parent = char.Torso end
    if char:findFirstChild("Pants") then char.Pants.Parent = char.Torso end
    for a, sc in pairs(char:children()) do if sc.Name == "ify" then sc:Destroy() end end
    local cl = Instance.new("StringValue", char) cl.Name = "ify" cl.Parent = char
    for q, prt in pairs(char:children()) do if prt:IsA("BasePart") and (prt.Name ~= "Head" or not prt.Parent:findFirstChild("NameTag", true)) then
      prt.Transparency = 0 prt.Reflectance = 0 prt.BrickColor = BrickColor.new("Bright yellow")
      if prt.Name:find("Leg") then prt.BrickColor = BrickColor.new("Br. yellowish green") elseif prt.Name == "Torso" then prt.BrickColor = BrickColor.new("Bright blue") end
      local tconn = prt.Touched:connect(function(hit) if hit and hit.Parent and game.Players:findFirstChild(hit.Parent.Name) and cl.Parent == char then Noobify(hit.Parent) elseif cl.Parent ~= char then tconn.disconnect()
    end
    end)
    cl.Changed:connect(function() if cl.Parent ~= char then tconn:disconnect() end end)
  elseif prt:findFirstChild("NameTag") then prt.Head.Transparency = 0 prt.Head.Reflectance = 0 prt.Head.BrickColor = BrickColor.new("Bright yellow")
  end
end
end
end

Try that. (I fixed up your code a tad as well)

This discussion is preserved as it was. New answers, comments, and votes are closed.