Values become nil after remote event, Client to Server

  1. What do you want to achieve? Keep it simple and clear!

I’m trying to make a map changing ui for my game.

  1. What is the issue? Include screenshots / videos if possible!

The values I send to the server return as nil.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I’ve tried to send it as a table and it still hasn’t worked.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

Client:

script.Parent.MouseButton1Click:Connect(function()
	print("Load")
	game.ReplicatedStorage.Events.MapChange:FireServer(true, "Template")
end)

Server

local Base = require(script.AdminControlBase)

game.ReplicatedStorage.Events.MapChange.OnServerEvent:Connect(function()
	Base.MapChange()
end)

Module Script:

local Base = {}

function Base.MapChange(mapval, mapname)
	print("map recieved")
	print(mapval)
	print(mapname)
	if mapval == true then
		local map = game.ServerStorage.Maps:FindFirstChild(mapname)
		local mapc = map:Clone()
		mapc.Parent = workspace.Map
		print("Map Changed")
	elseif mapval == false then
		local map = workspace.Map:GetChildren()

		for i, maps in ipairs(map) do
			maps:Destroy()
		end
	end
end

return Base

You forgot to add the variables in the function

game.ReplicatedStorage.Events.MapChange.OnServerEvent:Connect(function(player,mapval,mapname)
	Base.MapChange(mapval,mapname)
end)

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