How to edit other player "PlayerGUI" with local script

  1. What do you want to achieve? Keep it simple and clear!

(Just to let you know I’m not very good at English!)

I’m trying to make system that you can make player information card that’s like GUI.

  1. What is the issue? Include screenshots / videos if possible!

When I try to transfer information to another players Card Gui, error pups out:

image

This is how “Register” GUI looks.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

This is script that I made and its local script that is showing error.

local send = script.Parent.Send

local patientName = script.Parent.PatientName

local patientProblem = script.Parent.PatientProblem

local playerThatSent = game:GetService("Players").LocalPlayer

send.MouseButton1Click:Connect(function()
	local playerForCard = game.Players:FindFirstChild(patientName.Text)
	local otherPlayerGUi = playerForCard:WaitForChild("PlayerGui")
	
	otherPlayerGUi:FindFirstChild("PatientCard").Frame.PatientNameSystem.Text = patientName.Text
	otherPlayerGUi.PatientCard.Frame.PatientProblemSystem.Text = patientProblem.Text
	otherPlayerGUi.PatientCard.Frame.CardSent.Text = playerThatSent.Name
	otherPlayerGUi.PatientCard.Enabled = true
end)
1 Like

Also card GUI should look like this on other players GUI

You cannot access another player’s PlayerGui on the client. What do you need this for?

1 Like

I need it so I can set information’s to players GUi card. Like this, but it would show just on other client. And submit frame only show to certain players

I see. You can use RemoteEvents to tell the server your register information. I’m assuming theres some sort of system set in place to where the server knows which players need what information. So the server can then just tell the player the information you sent. If there isn’t, then the client can say which player they want to send the register information to.

Ok I will try that. If I will have any problems (which possibly I will have). Can I ask you?

Yes, I will keep this tab open.

1 Like

Replace :FindFirstChild(patientName.Text) to .LocalPlayer or game.Players:FindFirstChild(patientName.Text)

If it doesn’t work, remove game.Players:FindFirstChild(patientName.Text).

This is how your script should be:

local send = script.Parent.Send

local patientName = script.Parent.PatientName

local patientProblem = script.Parent.PatientProblem

local playerThatSent = game:GetService("Players").LocalPlayer

send.MouseButton1Click:Connect(function()
	local playerForCard = game.Players.LocalPlayer or game.Players:FindFirstChild(patientName.Text)
	local otherPlayerGUi = playerForCard:WaitForChild("PlayerGui")
	
	otherPlayerGUi:FindFirstChild("PatientCard").Frame.PatientNameSystem.Text = patientName.Text
	otherPlayerGUi.PatientCard.Frame.PatientProblemSystem.Text = patientProblem.Text
	otherPlayerGUi.PatientCard.Frame.CardSent.Text = playerThatSent.Name
	otherPlayerGUi.PatientCard.Enabled = true
end)

Or:

local send = script.Parent.Send

local patientName = script.Parent.PatientName

local patientProblem = script.Parent.PatientProblem

local playerThatSent = game:GetService("Players").LocalPlayer

send.MouseButton1Click:Connect(function()
	local playerForCard = game.Players.LocalPlayer
	local otherPlayerGUi = playerForCard:WaitForChild("PlayerGui")
	
	otherPlayerGUi:FindFirstChild("PatientCard").Frame.PatientNameSystem.Text = patientName.Text
	otherPlayerGUi.PatientCard.Frame.PatientProblemSystem.Text = patientProblem.Text
	otherPlayerGUi.PatientCard.Frame.CardSent.Text = playerThatSent.Name
	otherPlayerGUi.PatientCard.Enabled = true
end)
1 Like

You could also technically do this two other ways.

Client Automation

This way, you can have the client tell the server your card info, and then every other client will be able to read it when they want to, without the server giving them a personal invitation to read it. This method will be the most efficient, and the most clean. However, it is not good if you don’t want everybody to have the ability to read it.

Client > Server > Client

This way, the client tells the server their card info, and which player they want to send it to. It is slightly messier, but it is more secure, since only one other player can read the card info.

This is what I made now and it doesn’t work at all xD.

First local script:

local send = script.Parent.Send

local patientName = script.Parent.PatientName

local patientProblem = script.Parent.PatientProblem

local playerThatSent = game:GetService("Players").LocalPlayer

local RS = game:GetService("ReplicatedStorage")

send.MouseButton1Click:Connect(function()
	RS.PlayerCardSubmited.playerToSend.Value = patientName.Text
	RS.PlayerCardSubmited.playerProblem.Value = patientProblem.Text
	RS.PlayerCardSubmited.playerThatSent.Value = playerThatSent.Name
	
	
	RS.PlayerCardSubmited:FireServer()
end)

Second local script:

local RS = game:GetService("ReplicatedStorage")

local players = game:GetService("Players")

RS.PlayerCardSubmited.OnClientEvent:Connect(function()
	if RS.PlayerCardSubmited.playerToSend.Value == players.LocalPlayer.Name then
		players.LocalPlayer.PlayerGui:WaitForChild("PatientCard").Frame.PatientProblemSystem.Text = RS.PlayerCardSubmited.playerProblem.Value
		players.LocalPlayer.PlayerGui.PatientCard.Frame.PatientName.Text = players.LocalPlayer.Name
		players.LocalPlayer.PlayerGui.PatientCard.Frame.CardSent.Text = RS.PlayerCardSubmited.playerThatSent.Value
		players.LocalPlayer.PlayerGui.PatientCard.Enabled = true
	else
	end
end)

image

These are being changed locally, the server has no idea about these changes. So the data will appear empty to the server and the other client getting the information.

Look at the 2 scripts that I posted, it could work.

How do I make it so it doesn’t change locally? Do you have link to some roblox page or something

It doesn’t work. Both of them show card on screen of person that sent it.

Simply tell the server the information using a list or a dictionary.

send.MouseButton1Click:Connect(function()
	RS.PlayerCardSubmited:FireServer({
        Reciever = patientName.Text,
        Problem = patientProblem.Text,
        -- didn't include PlayerThatSent
    })
end)
1 Like

Oh, but how do I check if information’s are needed to be send to that person. Like this or some other way? I really don’t know

RS.PlayerCardSubmited.OnClientEvent:Connect(function()
	if Reciever == patientName.Text then
		
	end
end)

Um… Hello are you still here? I don’t want to be strenuous or anything.

This is what the client script would look like:

local RS = game.ReplicatedStorage
local player = game.Players.LocalPlayer

send.MouseButton1Click:Connect(function()
	RS.PlayerCardSubmited:FireServer({
        Reciever = patientName.Text,
        Problem = patientProblem.Text,
    })
end)

RS.PlayerCardSubmited.OnClientEvent:Connect(function(info, sender)
	if sender != player then
		player.PlayerGui:WaitForChild("PatientCard").Frame.PatientProblemSystem.Text = info.Problem
		player.PlayerGui.PatientCard.Frame.PatientName.Text = player.Name
		player.PlayerGui.PatientCard.Frame.CardSent.Text = sender.Name
		player.PlayerGui.PatientCard.Enabled = true
	end
end)

And this is how the server would handle that:

local function filter(problem, player) -- you MUST filter the problem text because the player is sending text to somebody else
    return problem -- TODO: Filter this text
end

RS.PlayerCardSubmited.OnServerEvent:Connect(function(player, info)
    if type(info) ~= "table" then return player:Kick("Invalid remote data.") end
    if info.Problem and info.Reciever then
        info.Problem = tostring(info.Problem)
        info.Reciever = tostring(info.Reciever)
        local other = game.Players:FindFirstChild(info.Reciever)
        if other then
            RS.PlayerCardSubmited:FireClient(other, filter(tostring(info.Problem)), player)
        end
    end
end)
1 Like

Others client cant access others clients player gui, only the server can access it.

I already said this, up in the first reply.