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

Can someone fix me this script? its a fire all touch interest script (contact me Someone#9827)

for i,v in next, workspace:GetDescendants() do
    if v:IsA'TouchTransmitter' then
        table.insert(Tab,v)
    end
end
local plr=game:GetService'Players'.LocalPlayer
spawn(function()
    local UIS=game:GetService'UserInputService'
    UIS.InputBegan:Connect(function(Key)
        if Key.KeyCode==Enum.KeyCode.H and not UIS:GetFocusedTextBox() then
            for i,v in next,Tab do
                if v:IsA'TouchTransmitter' then
                    print'Fired!'
                    if firetouchinterest then
                        firetouchinterest(plr.Character.HumanoidRootPart,v.Parent,0)
                        wait()
                        firetouchinterest(plr.Character.HumanoidRootPart,v.Parent,1)
                    end
                end
            end
        end
    end)
end)

it says : bad argument #1 to 'insert'(table expected, got nil)

1 answer

You forgot to add the table..

try this :


local Tab = {}

for i,v in next, workspace:GetDescendants() do
    if v:IsA'TouchTransmitter' then
        table.insert(Tab,v)
    end
end
local plr=game:GetService'Players'.LocalPlayer
spawn(function()
    local UIS=game:GetService'UserInputService'
    UIS.InputBegan:Connect(function(Key)
        if Key.KeyCode==Enum.KeyCode.H and not UIS:GetFocusedTextBox() then
            for i,v in next,Tab do
                if v:IsA'TouchTransmitter' then
                    print'Fired!'
                    if firetouchinterest then
                        firetouchinterest(plr.Character.HumanoidRootPart,v.Parent,0)
                        wait()
                        firetouchinterest(plr.Character.HumanoidRootPart,v.Parent,1)
                    end
                end
            end
        end
    end)
end)

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