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 transfer a table from a module to a script? (SOLVED)

I was messing around with a lightning module I found, and was wanting to transfer a table to the server script so I can make a fading effect. I have no idea how to transfer a table from a module to a server script though. Help?

MODULE:

----------------------------
local Full = {} --THIS IS THE TABLE IM TRYING TO TRANSFER TO A SERVER SCRIPT
-----------------------------

math.randomseed(tick())

local mlaser = script.Ref -- Template for the segments

local random, log, tau = math.random, math.log, math.pi*2

-- Render a segment
local function RenderSegment(start, stop, powar, parent)
	local len = (start - stop).magnitude
	local new = mlaser:clone()
	new.CFrame = CFrame.new((start + stop)/2, stop)*CFrame.Angles(math.pi/2, 0, 0)
	if len < 1 then
		new.Mesh.Scale = Vector3.new(powar, len, powar)
		new.Size = Vector3.new(0.5, 1, 0.5)
	else
		new.Mesh.Scale = Vector3.new(powar, 1, powar)
		new.Size = Vector3.new(0.5, len, 0.5)
	end
	new.Parent = parent
	
	
	-----------------------------
	table.insert(Full, new)
	-----------------------------
	
	
	
end

-- Generates lightning
local function Generate(start, stop, bfactor, jaggedness, thickness, iterations)
	local parent = Instance.new('Model', workspace)
	parent.Name = "Lightning"
	local theta = math.atan(2*jaggedness)
	local segmentList = {{start, stop}}
	
	for i = 1, iterations do
		local _segmentList = segmentList
		segmentList = {}
		for _, v in ipairs(_segmentList) do
			-- Offset the midpoint randomly on the plane perpendicular to the current line
			local dist = (v[1] - v[2]).magnitude
			local midPoint = (v[1] + v[2])/2
			local dVect = CFrame.new(midPoint, v[2])
			midPoint = (dVect*CFrame.Angles(0, 0, random()*tau)*CFrame.new(0, random()*dist*jaggedness, 0)).p
			
			-- Generate branch
			local branchLen = bfactor*dist
			local direction = (dVect*(CFrame.Angles(0, 0, random()*tau)*CFrame.Angles(0, random()*theta, 0))).lookVector
			local branch = direction*branchLen + midPoint		

			if i ~= iterations then
				segmentList[#segmentList + 1] = {v[1], midPoint}
				segmentList[#segmentList + 1] = {midPoint, v[2]}
				segmentList[#segmentList + 1] = {midPoint, branch}
			else
				local distl = dist*thickness
				RenderSegment(v[1], midPoint, distl, parent)
				RenderSegment(midPoint, v[2], distl, parent)
				RenderSegment(midPoint, branch, branchLen*thickness, parent)		
			end
		end
	end
end



return Generate

Here's the ServerScript if it helps:

while true do
	wait(1)
	require(game.ServerScriptService.Lightning)(script.Parent.Position, workspace.End.Position, 0.35, 0.35, 0.2, 4)
end

1 answer

Nevermind, figured it out myself. Just did it all in the module.

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