Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Is it possible?

Am I able to make it so that a player could type information onto a GUI that I made, and have it so that when another player mouses over/clicks them, it shows what the player type into the GUI? (EX: Player 1 types "Cake" into the GUI's text box. Player 2 hovers mouse over Player 1. GUI Pop's up showing "Cake") I know a large majority of basic scripting, so the only thing I really need help with is making the GUI that comes up on click/hover display the text box info.

1 answer

Yep, it is possible. I recommend putting it all in the same LocalScript, in StarterGui. In this answer, I'm assuming you already have both GUI's created, and they look like this, and OnHoverGui.MainFrame.Visible is false.

First, define the LocalPlayer, the GUI's, and wait for them to load.

local plr = game:GetService('Players').LocalPlayer
local PlayerGui = game:GetService('Players').LocalPlayer:WaitForChild('PlayerGui') -- Even if script.Parent isn't the player's PlayerGui, it can find it
local InputGui = PlayerGui:WaitForChild('MsgInputGui')
local OnHoverGui = PlayerGui:WaitForChild('OnHoverGui')

Then, you might want to define some variables for the Frames, TextBoxes and TextLabels, so it's easier to manipulate them.

local InputFrame = InputGui:WaitForChild('MainFrame')
local OnHoverFrame = OnHoverGui:WaitForChild('MainFrame')
local InputBox = InputFrame:WaitForChild('InputBox')
local MsgLabel = OnHoverFrame:WaitForChild('MsgLabel')

Afterwards, set up the anonymous function that'll handle the supposed "OnHover" event. Since you'd have to put ClickDetectors in all of the parts in all characters to use OnHover, let's use the Moveevent of the Player's mouse.

plr:GetMouse().Move:connect(function()

local Target = plr:GetMouse().Target

if Target == nil then OnHoverFrame.Visible = false; return end -- Mouse isn't hovering a part

if Target.Parent == workspace then OnHoverFrame.Visible = false; return end -- It's just a normal part, not part of a character for sure

local TargetPlayer = game:GetService('Players'):GetPlayerFromCharacter(Target.Parent)

if TargetPlayer==nil then OnHoverFrame.Visible = false; return end -- Not part of a player's character

local TargetPlayersMessage = TargetPlayer:WaitForChild('PlayerGui'):WaitForChild('MsgInputGui'):WaitForChild('MainFrame'):WaitForChild('InputBox').Text -- Get the target player's message

MsgLabel.Text = TargetPlayersMessage

OnHoverFrame.Visible = true

end)

And done! Final script:

local plr = game:GetService('Players').LocalPlayer
local PlayerGui = game:GetService('Players').LocalPlayer:WaitForChild('PlayerGui') -- Even if script.Parent isn't the player's PlayerGui, it can find it
local InputGui = PlayerGui:WaitForChild('MsgInputGui')
local OnHoverGui = PlayerGui:WaitForChild('OnHoverGui')

local InputFrame = InputGui:WaitForChild('MainFrame')
local OnHoverFrame = OnHoverGui:WaitForChild('MainFrame')
local InputBox = InputFrame:WaitForChild('InputBox')
local MsgLabel = OnHoverFrame:WaitForChild('MsgLabel')

plr:GetMouse().Move:connect(function()

local Target = plr:GetMouse().Target

if Target == nil then OnHoverFrame.Visible = false; return end -- Mouse isn't hovering a part

if Target.Parent == workspace then OnHoverFrame.Visible = false; return end -- It's just a normal part, not part of a character for sure

local TargetPlayer = game:GetService('Players'):GetPlayerFromCharacter(Target.Parent)

if TargetPlayer==nil then OnHoverFrame.Visible = false; return end -- Not part of a player's character

local TargetPlayersMessage = TargetPlayer:WaitForChild('PlayerGui'):WaitForChild('MsgInputGui'):WaitForChild('MainFrame'):WaitForChild('InputBox').Text -- Get the target player's message

MsgLabel.Text = TargetPlayersMessage

OnHoverFrame.Visible = true

end)

Hope it helps! :)

If it doesn't work, or you don't understand something, please comment, and I'll do my best to fix it/explain.

This discussion is preserved as it was. New answers, comments, and votes are closed.