Hello, I am trying to make it so you can make your private server have a certain amount of players in it, for example you type in 5 and only 5 people can join now. Whenever you type it in it sends to a local script from the text box which is read by a server script after being fired, then it sets _G.maxPlayers
to your variable, but it sets it to my name when printing.
Code:
--Local Script
local button = script.Parent
local RemoteEvent = game:GetService("ReplicatedStorage").maxPlayers
local TextBox = script.Parent.Parent.TextBox
button.MouseButton1Click:Connect(function()
print(script.Parent.Parent.TextBox.Text)
RemoteEvent:FireServer(tonumber(script.Parent.Parent.TextBox.Text))
end)
local function maxPlayersFunction(maxPlayersValue)
print(maxPlayersValue)
_G.maxPlayers = maxPlayersValue
end
RemoteEvent.OnServerEvent:Connect(maxPlayersFunction)
Iām not good with code, so if anyone can help that would be great!