Player Gui (Error)

I wrote a script which is supposed to make a particular Ui visible when a certain event happens, however it’s not working.

Script:

Roblox Script Error

Output:

Roblox Script Error(1)

1 Like

Player isn’t a return value of OnClientInvoke(). Since it’s a local script, why not just do game.Players.LocalPlayer.PlayerGui? Local player will ALWAYS be you.

But, I want to make that Ui visible to Player 1 specifically, how will the script know that the local player is Player 1?

@sleitnick Can you please help?

Can you describe more of what you’re trying to do? What are both the server and client(s) doing in this scenario?

Should I just send you a copy of the game in DM’s and tell you everything there?

Or just post the whole of your code as text and not an image…

Ok sent you a copy of the game, and explained the concept of the game and how everything works.

First off, OnClientInvoke does NOT Return a player instance.

Second off, for “Player1Gui” define it as
local Player1Gui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
That will work for you.

1 Like

What is that supposed to mean?

1 Like

You used RemoteFunction.OnClientInvoke = function(Player1)

When OnClientInvoke is called, the only values you receive from it are values you sent.

Unless you did, RemoteFunction:InvokeClient(Player, Player)
(first player value is to define whos client to send a request to, second one if a value your passing to the client.)

Yes, I did define the Player Instance when using Invoking the client.

May you please send a photo of what you sent to the client…? (send a photo of your server script)

e.g. "RemoteFunction:InvokeClient(Player1, Value1)

Sure! Here’s an image of the invoking client part: https://gyazo.com/13c461b4c0b43e29d6d36d7609c7684c

Yeah you only Invoked the client, you didn’t send a player value.

 --use this to your liking.

RemoteFunction.OnClientInvoke = function()
local Player1Gui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
--rest of your code here
end)

Ah, I see what the problem is.

So a question: Who are you trying to fire this event to? Player1?

local Player1Input = GuiActivationFunctionPlayer1:InvokeClient(game.Players:GetPlayerFromCharacter(Player1))

So the problem here is that the first parameter of a Remote Function is the player you’re trying to fire it to. And on the client side, you can’t see that first parameter, it’s only for the server to know. So, you’ll instead want to fire to the first parameter, but pass Player1 in the second parameter, like so:

local Player1Input = GuiActivationFunctionPlayer1:InvokeClient(game.Players:GetPlayerFromCharacter(Player1), game.Players:GetPlayerFromCharacter(Player1))

This will

  1. Fire the Remote Event to the first parameter, which is Player1
  2. Also pass Player1 to the client in the second parameter

To clarify: The first parameter, which is the client to fire to, will not show up for the client, only for the server.

Here’s the Roblox API Reference to it: RemoteFunction | Documentation - Roblox Creator Hub

Let us know how it goes!

But, how will I identify if the local player is the same as Player 1?

It worked, thank you so much for your help!

1 Like