I need help carrying data from a server script to a local script using remote events

So I am making a game where there are 2 teams and once each one has reached 3 players the round starts. The issue I am having is when the players are waiting they have a screenGUI that says “leave” so they can leave the game queue. Once the game starts I am trying to make the screenGUI disappear. So I have a server script in the workspace and a local script in PlayerGui. this is the server script.

local players = Team1:GetPlayers()
		local player1 = players[1]
		local GameStart = ReplicatedStorage:FindFirstChild("GameStart")
		local gui = "LeaveCourt1Spot1A"
		GameStart:FireClient(player1, gui)

and this is the local script

GameStart.OnClientEvent:Connect(function(player, gui)
	wait(3)
	local gui1 = player.PlayerGui:FindFirstChild(gui)
	gui1.Enabled = false
end)

The error I am getting is attempt to index nil with findfirstchild.

OnClientEvent doesn’t provide the player parameter. Get rid of that parameter and it should work.

Fixed Version:

local player = game.Players.LocalPlayer
GameStart.OnClientEvent:Connect(function(gui)
	wait(3)
	local gui1 = player.PlayerGui:FindFirstChild(gui)
	gui1.Enabled = false
end)
1 Like