[URGENT!] RemoteEvent Issue

Hey everyone!
Everytime I use the scripts, they don’t work as intended.

The Name turns out into nothing (just “”)
And the Number would turn out as nil (I put in a number)

LocalScript:

local LobbyMaker = game:GetService("ReplicatedStorage"):WaitForChild("CreateLobby")

local CreateButton = script.Parent:WaitForChild("CREATE")
local Scrolly = script.Parent:WaitForChild("Scrolly")

local LobbyName = Scrolly.LobbyName.TxtBoxFrame.TextBox.Text
local ServerSize = tonumber(Scrolly.ServerSize.TxtBoxFrame.TextBox.Text)

CreateButton.MouseButton1Click:Connect(function()
	
	LobbyMaker:FireServer(LobbyName, ServerSize)

end)

Server Script:

local LobbyDuplicate = game:GetService("ServerStorage"):WaitForChild("LobbyDuplicate"):Clone()
local CL  = game:GetService("ReplicatedStorage"):WaitForChild("CreateLobby")
local TS = game:GetService("TextService")

CL.OnServerEvent:Connect(function(player, LobbyName, ServerSize)
	print(player)
	print(LobbyName) -- Prints ""
	print(ServerSize) -- Prints "nil"
	
	-- print(TS:FilterStringAsync(LobbyName, player.UserId, Enum.TextFilterContext.PublicChat)) [NOT DONE]
end)

So the reason is not your RemoteEvent, its the values. They dont get updated in mid-game. Try it like that:

local LobbyMaker = game:GetService("ReplicatedStorage"):WaitForChild("CreateLobby")

local CreateButton = script.Parent:WaitForChild("CREATE")
local Scrolly = script.Parent:WaitForChild("Scrolly")


CreateButton.MouseButton1Click:Connect(function()
	local LobbyName = Scrolly.LobbyName.TxtBoxFrame.TextBox.Text
    local ServerSize = tonumber(Scrolly.ServerSize.TxtBoxFrame.TextBox.Text)
	LobbyMaker:FireServer(LobbyName, ServerSize)

end)

Oh and dont use WaitForChild in a ServerScript when you know that it exists

Along with what Fausto said, I would print player.Name instead of player since it is meant to get a string. Unless player works too, then that is my bad.

2 Likes

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