The connection problem between client and server

The server doesn’t read me the gui generated by a client. How can I fix it?

LocalScript

script.Parent.TextButton.MouseButton1Click:Connect(function()
	local e = Instance.new("ImageButton", game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame)
	e.Size = UDim2.new(0,200,0,200)
	game.ReplicatedStorage.RemoteEvent:FireServer()
end)

Script

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(eee)
	for j,e in pairs(eee.PlayerGui.ScreenGui.Frame:GetChildren()) do
		print(e)
	end
end)

ewee

3 Likes

any errors in the output window?

The creation of instances on the client is not replicated to the server for security reasons. If you want to create a UI element and in the rare situation where you need to interact with it on the server, instruct the server to make it.

2 Likes

But how do I make the gui visible only for the players?

You can parent it to a player’s PlayerGui, same as you do on the client now.

1 Like