Table.insert() not working?

i’m trying to insert a part into a global table but even if i switched to normal local tables it still wouldn’t work?

code:

local params = RaycastParams.new()
params.FilterType = Enum.RaycastFilterType.Exclude
_G.params = {
	char,
	cam,
}
params.FilterDescendantsInstances = _G.params

function visualizeRay(orig, dir, name, brickcolor, lifetime, overrideParent)
	local part = Instance.new("Part", overrideParent or workspace.Misc.Debug)
	table.insert(part, _G.params) -- issue
	part.Name = "RaycastVisualization"
	part.Transparency = .5
	part.Anchored = true
	part.CanCollide = false
	part.CastShadow = false
	if brickcolor then
		part.BrickColor = brickcolor
	else
		part.BrickColor = BrickColor.new("Really red")
	end
	part.Material = Enum.Material.Neon
	part.Size = Vector3.new(.1,.1,dir.Magnitude)
	part.CFrame = CFrame.new(orig,orig+dir)*CFrame.new(0,0,-dir.Magnitude/2)
	if name then
		print(part.BrickColor.Name .. ": " .. name)
	end
	game.Debris:AddItem(part, lifetime or 10)
	return part
end

I only issue I could think of is that your not running the function.

you’re trying to insert params into part

-- table.insert(table, value)
table.insert(_G.params, part)

i’ve made this mistake before too

2 Likes

i’m so dumb
thank u : )

[30 word limit]

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.