Having Trouble With Remote Event

Hello all,

I’m having trouble with this RemoteEvent. The RemoteEvent (CreateLobby) is firing, but the values are not being passed along to the server. Here is the localscript:

local ReplicatedStorage = game:GetService('ReplicatedStorage')

function onClick(player)

	game.StarterGui.Click1:Play()

	local name = script.Parent.Parent.NameBox.Text
	
	local players = script.Parent.Parent.PlayerBox.Text
	local storyline = 'Map 1'

	local difficulty = ''
	local invOn = false

	if script.Parent.Parent.DifficultyLabel.TextColor3 == '255, 255, 0' then
		difficulty = 'Medium'
	elseif script.Parent.Parent.DifficultyLabel.TextColor3 == '85, 255, 0' then
		difficulty = 'Easy'
	else	
		difficulty = 'Hard'
	end

	if script.Parent.Parent.TextButtonInvOn.BackgroundTransparency == 0.5 then
		invOn = true
	else
		invOn = false
	end
	
	print(name)
	print(players)
	print(storyline)
	print(difficulty)
	print(invOn)
	
	ReplicatedStorage.CreateLobby:FireServer(player, name, players, difficulty, storyline, invOn)

end

script.Parent.MouseButton1Click:Connect(onClick)

All of the print statements are running and displaying the values that they should. Here is the CreateLobby Script inside of ServerScriptService:

function createLobby(player, name, players, difficulty, storyline, invOn)

	local lobby = Instance.new('Folder')
	lobby.Name = name
	lobby.Parent = game.Workspace
	
	local InviteOnly = Instance.new('BoolValue')
	InviteOnly.Name = 'InviteOnly'
	InviteOnly.Parent = lobby
	InviteOnly.Value = invOn.Value
	
	local Map = Instance.new('StringValue')
	Map.Name = 'Map'
	Map.Parent = lobby
	Map.Value = storyline.Value
	
	
	
end
game.ReplicatedStorage.CreateLobby.OnServerEvent:Connect(createLobby)

Here is the error displayed in the output:

I’m not really sure what to make of this. Thanks for any and all help :slight_smile:. If you need anymore info, just let me know.

You do not need to pass the player argument in the :FireServer() function. It’s automatically set.

3 Likes

The first argument on the server will always be the Client/Player that fired the event regardless if you passed it or not.

ReplicatedStorage.CreateLobby:FireServer(name, players, difficulty, storyline, invOn)

Just remove the player argument in the client and test it again. (Like in this example ^)