Module script not passing from server to client

  1. I want for the server script to pass over a table from the server to the client.

  2. What I receive on the client is an empty table, with nothing inside of it, but on the server I receive a table full of stuff.

  3. I initially discovered that I named the part of the module wrong, so I fixed that, but it’s still not doing anything.

The script is fully intended to make it so after someone presses a button on a gui, it will fire a remote which goes onto the server and puts a table onto a module script, which is meant to be able to be seen by both the client and the server.

Server script: (Passing the table onto the module script)

script.Parent.RemoteEvent.OnServerEvent:Connect(function(plr, variable)
	if plr == game.ReplicatedStorage.Deli_Station.Customer.Value then
		local findSubCreation = game.ReplicatedStorage.Deli_Station.Value:FindFirstChild("SubCreation")
		if findSubCreation then
			local required = require(findSubCreation)
			required.Deli_Part = variable
			print(variable, required.Deli_Part)
			game.ReplicatedStorage.PleaseWait:Clone().Parent = plr.PlayerGui
			game.ReplicatedStorage.Deli_Station.Value.PlayerGui.PleaseWait:Remove()
			game.ReplicatedStorage.DeliDisplay:Clone().Parent = game.ReplicatedStorage.Deli_Station.Value.PlayerGui
			script.Parent:Remove()
		end
	end
end)

Client script: (The script that is meant to look at the table through the module script, this script is created inside of the DeliDisplay gui)

local ComponentsModule = game.Players.LocalPlayer:FindFirstChild("SubCreation")
local Components = require(ComponentsModule)
local Deli = Components.Deli_Part
local Template = script.Parent.Needs.Holder.Template
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local ComponentsSelected = {}
local HoverThing = game.ReplicatedStorage.DisplayType:Clone()

local function findHover()
	local camera = workspace.CurrentCamera
	local startPos = camera.CFrame.Position
	local endPos = mouse.Hit.Position
	local params = RaycastParams.new()
	params.FilterDescendantsInstances = {workspace.Border, player.Character}
	local direction = (endPos - startPos).Unit
	local distance = (endPos - startPos).Magnitude
	local result = workspace:Raycast(startPos, direction * distance, params)
	return result
end

print(Components)

for i, v in pairs(Components) do
	print(v, Components[i])
	for variable, has in pairs(Components[i]) do
		print(variable, has)
		if has == true then
			local Cloned = Template:Clone()
			Cloned.Name = variable
			Cloned.Text = variable
			Cloned.Parent = script.Parent.Needs.Holder
			Cloned.Visible = true
		end
	end
end

Template:Destroy()

local SizeY = 1 / (#script.Parent.Needs.Holder:GetChildren() - 1)

for i, v in pairs(script.Parent.Needs.Holder:GetChildren()) do
	if v:IsA("TextLabel") then
		v.Size = UDim2.new(v.Size.X.Scale, 0, SizeY, 0)
	end
end

If you understand the issue, please let me know, it would be greatly appreciated.

The thing is you do not have a remote event,you need a remote event to send to the client

You only have the server script,but there is nothing on the client script

And also,just do module script towards client acript

I’m honestly not entirely certain what the problem is. Are you trying to pass data from client to server (or vice versa) through a module script? If so, module scripts run on a specific machine and doesn’t automatically copy data across and must have all data pushed through a remote event (amd received of course)

Is the problem that a table you are trying to send through a remote not working? If so we will need to know what data specifically you are trying to send. If I recall correctly there are some rules about what data can be in a table sent by a remote event (I’d have to check).

Is the problem something else and I just don’t quite understand?

I was trying to send a table to the client through a module script, since I thought that you could read module script changes across servers and clients. If you can’t, should I just use a RemoteEvent?

Yup. Remote events are pretty much the only way.

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