Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would I access someone else's PlayerGui in a localscript?

Asked by
Astilev 30
8 years ago

I'm trying to insert a message into someone else's PlayerGui through a localscript. Is that possible? If so, how?

3 answers

Log in to vote
0
Answered by 8 years ago

like a message as in

Instance.new('Message')

?

0
yeah but parent it to their PlayerGui Astilev 30 — 8y
0
when I try to parent it to their PlayerGui, it returns an error "PlayerGui is not a valid member of Player" Astilev 30 — 8y
0
Can you show me what your script looks like? DevsAtWork 0 — 8y
0
Oh my goodness. rexbit 707 — 8y
Ad
Log in to vote
0
Answered by 8 years ago
Edited 8 years ago

Coming from a noob, I think

local PlayerAdded = game.Players.PlayerAdded:connect(function(plr)

local Message = Instance.new("Message",game.Players.LocalPlayer.PlayerGui)

Message.Text = "You're text"    

end)


So when the Instance.New message goes into the LocalPlayers' PlayerGUI

Log in to vote
0
Answered by 8 years ago
Edited 8 years ago

If you're using FilteringEnabled (and possibly even if you're not, I'm not sure), you will need to have RemoteEvents. Assuming your RemoteEvent is in the workspace and is named RelayMessage, something like this:

--Server script
workspace.RelayMessage.OnServerEvent:connect(function(sender, target, msg)
    workspace.RelayMessage:FireClient(target, msg)
end)
--Local script
workspace.RelayMessage.OnClientEvent:connect(function(msg)
    --deal with msg here
end)
--Send a message to someone else like this:
workspace.RelayMessage:FireServer(somePlayer, someMsg)

Note: a proper server-side function might make sure of the following things to prevent exploiters/hackers from doing too much damage:

  • That the message is appropriate and not ridiculously long (ex it could be a number referring to a pre-made message if you wanted to be 100% safe)
  • That the sender isn't spamming people or the server using a bot (if they are, you should kick them)

Answer this question