Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i FindFirstChild() without a argument?

Asked by
qwrn12 85
8 years ago

I'm trying to make it so that what ever is in this spot E=game.Lighting.E["Baton"]:Clone(); where baton is can be found no matter what is there or what name it has i tried to use find first child but it didn't work because i don't have a argument but i cant find how to do it without one here is the full script

local player=game.Players.LocalPlayer
local y=1
local l=1
local c=1
local tools={
    E=game.Lighting.E["Baton"]:Clone();
    Q=game.Lighting.Q["BillyClubRiotShield"]:Clone();
    R=game.Lighting.R["LE-AR"]:Clone();
    F=game.Lighting.F["LE-P1"]:Clone();
    G=game.Lighting.G["LE-S1"]:Clone();
}
game:GetService("UserInputService").InputBegan:connect(function(inputObject)
    if inputObject.KeyCode.Name=="Slash"then
        while l == 1 do
            y=3
            player.Character.Humanoid:UnequipTools()


        print "yay"
        wait()
        end

        y=1
        elseif inputObject.KeyCode.Name=="Return" then
        l = 2
        wait()
        l = 1
        else
        local tool=tools[inputObject.KeyCode.Name]
        if tool then
            if y==1 then
                player.Character.Humanoid:EquipTool(tool)
                y=2
                if inputObject.KeyCode.Name == "E" then
                    player.PlayerGui.InventoryGui.Frame.Frame.E.BorderColor3=Color3.new(13/255,120/255,177/255)
                elseif inputObject.KeyCode.Name == "Q" then
                    player.PlayerGui.InventoryGui.Frame.Frame.Q.BorderColor3=Color3.new(13/255,120/255,177/255)
                elseif inputObject.KeyCode.Name == "R" then
                    player.PlayerGui.InventoryGui.Frame.Frame.R.BorderColor3=Color3.new(13/255,120/255,177/255)
                elseif inputObject.KeyCode.Name == "F" then
                    player.PlayerGui.InventoryGui.Frame.Frame.F.BorderColor3=Color3.new(13/255,120/255,177/255)
                elseif inputObject.KeyCode.Name == "G" then
                    player.PlayerGui.InventoryGui.Frame.Frame.G.BorderColor3=Color3.new(13/255,120/255,177/255)
                end
            elseif y==2 then
                player.Character.Humanoid:UnequipTools()
                if inputObject.KeyCode.Name == "E" then
                    player.PlayerGui.InventoryGui.Frame.Frame.E.BorderColor3=Color3.new(27/255,42/255,53/255)
                elseif inputObject.KeyCode.Name == "Q" then
                    player.PlayerGui.InventoryGui.Frame.Frame.Q.BorderColor3=Color3.new(27/255,42/255,53/255)
                elseif inputObject.KeyCode.Name == "R" then
                    player.PlayerGui.InventoryGui.Frame.Frame.R.BorderColor3=Color3.new(27/255,42/255,53/255)
                elseif inputObject.KeyCode.Name == "F" then
                    player.PlayerGui.InventoryGui.Frame.Frame.F.BorderColor3=Color3.new(27/255,42/255,53/255)
                elseif inputObject.KeyCode.Name == "G" then
                    player.PlayerGui.InventoryGui.Frame.Frame.G.BorderColor3=Color3.new(27/255,42/255,53/255)
                end
                y=1
            end
        end
    end
end)

game:GetService("UserInputService").InputBegan:connect(function(inputObject)
    if inputObject.KeyCode.Name == "C" then
        if c == 1 then
            player.PlayerGui.Invintory.Frame.Visible = true
            c=2
        elseif c == 2 then
            player.PlayerGui.Invintory.Frame.Visible = false
            c=1
        end
    end
end)

so can anyone help me or is it impossible

0
FindFirstChild without an argument, which argument is the target, is completely pointless. It is also inefficient to not maintain specific tool names which makes the script needlessly complicated. Marios2 360 — 8y

1 answer

Log in to vote
0
Answered by
1waffle1 2908 Trusted Badge of Merit Moderation Voter Community Moderator
8 years ago

If you want to literally get the first child, use game.Lighting.E:GetChildren()[1].

GetChildren returns a table of the object's children.

0
thanks for all your help qwrn12 85 — 8y
Ad

Answer this question