I've got an admin gui in my game, admins have to type a players name in, then press confirm to set that player as the one that is affected. The issue is that in filtering enabled, I don't know how to set the player value to what the text is. This is what I tried:
script.ConfirmPlayer.OnServerEvent:Connect(function(Player)
if Player.Name == "soutpansa" or Player.Name == "WakaFlockajr" or Player.Name == "Night_Moons"
or Player.Name == "bigbus92" or Player.Name == "Shirou_XI" then
script.PlayerValue.Value = Player.PlayerGui.MainHud.ControlPanel.Person.Text
end
end)
A local script fires the event from the gui. I'm not sure what else to try here in order to set the PlayerValue.
Thanks for reading
Edit: Server script:
local DoPlayer = script.ConfirmPlayer
function DoPlayer.OnServerInvoke(Player)
if Player.Name == "soutpansa" or Player.Name == "WakaFlockajr" or Player.Name == "Night_Moons"
or Player.Name == "bigbus92" or Player.Name == "Shirou_XI" then
script.PlayerValue.Value = Player:FindFirstChild("PlayerGui"):FindFirstChild("MainHud").ControlPanel.Person.Text
end
end
(I know im supposed to return something here, but idk what)
local script:
wait(1)
local Player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
local Name = script.Parent.Parent.Person.Text
Player.Backpack.Control_Panel.ConfirmPlayer:InvokeServer()
end)

8 comments
While using a RemoteFunction, I get the error: "attempt to index a nil value" (line 7, which is script.PlayerValue.Value = Player:FindFirstChild("PlayerGui"):FindFirstChild("MainHud").ControlPanel.Person.Text
Repost this question or just edit this question with the new code so I can see.
There, I edited it
On line 4, instead of doing all that just do 'return Player:FindFirstChild("PlayerGui"):FindFirstChild("MainHud").ControlPanel.Person.Text' then in the local script on the line where you invoke the server, make it a variable and add an if statement to see if the RemoteFunction returns a value, which in this case is the Text, and set the value of 'PlayerValue' to the variable where you invoked it.
can you give an example of making it a variable and checking if it returned anything?
I didn't test this before-hand but it should be sufficient enough for an example. --CLIENT-- local var = remoteFunction:InvokeServer() if var then print(var.Value) end --SERVER -- function getData.OnServerInvoke(player) local data = workspace:FindFirstChild(player.Name).Humanoid.Health return data end
Sorry for the late response. But I still get the error: "attempt to index a nil value" on the same line. How about firing another remote event? How would I go about making it work like t hat?
Nevermind, I got it to work. Instead of returning anything, I passed Name through the function. Name = script.Parent.Parent.Person.Text. local var = Player.Backpack.Control_Panel.ConfirmPlayer:InvokeServer(Name). Now it works fine on the actual game. Thanks for your help