[strike]With Filtering enabled player’s GUIs don’t replicate. When you fire a RemoteEvent with an instance, it only passes the hashcode for the instance so the server knows exactly what instance you are talking about, not an exact clone of the instance. Since the GUI object doesn’t exist on the server, it’s nil in the function arguement.[/strike]
On second thought, that might not be applying right now since it’s happening inversely (server->client). It’s more probably just that the client never receives the GUI clone, since it’s never parented, and so nil for the player. Try Parenting the GUI to ReplicatedStorage and cloning it locally.
Oh. Okay. How, then, can I get the instance from the server to the player’s player gui?
now is the time for more hacks!
If you want the server to handle the placement, place the GUI in Backpack with a LocalScript that places it in PlayerGui.
If you want the client to handle the placement, tell the client to grab the GUI and clone it into the PlayerGui.
So I’m moving my edited copy of the ScreenGui to game.ReplicatedStorage as so:
gui.Parent = game.ReplicatedStorage
Then I am doing this in my localscript:
game.ReplicatedStorage.CubeRemoteEvents.GameOverGuiCreated.OnClientEvent:connect(function() repeat wait() until game.ReplicatedStorage:FindFirstChild("GameOverGui") game.ReplicatedStorage.GameOverGui.Parent = script.Parent if script.Parent:FindFirstChild("GameplayHUD") then script.Parent.GameplayHUD:Destroy() end end)
But the Gui is never being replicated onto the client’s ReplicatedStorage…
local rs = game:GetService("ReplicatedStorage") local gui = script.Parent gui.Parent = rs script.Disabled = true
local rs = game:GetService("ReplicatedStorage") local playerGui = script.Parent rs.CubeRemoteEvents.GameOverGuiCreated.OnClientEvent:Connect(function() local gameOverGui repeat task.wait() gameOverGui = rs:FindFirstChild("GameOverGui") until gameOverGui gameOverGui.Parent = playerGui local gameplayHUD = playerGui:FindFirstChild("GameplayHUD") if gameplayHUD then gameplayHUD:Destroy() end end)