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

Is it possible?

Asked by 9 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

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

Log in to vote
1
Answered by
RafDev 109
9 years ago

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.

1local plr = game:GetService('Players').LocalPlayer
2local PlayerGui = game:GetService('Players').LocalPlayer:WaitForChild('PlayerGui') -- Even if script.Parent isn't the player's PlayerGui, it can find it
3local InputGui = PlayerGui:WaitForChild('MsgInputGui')
4local 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.

1local InputFrame = InputGui:WaitForChild('MainFrame')
2local OnHoverFrame = OnHoverGui:WaitForChild('MainFrame')
3local InputBox = InputFrame:WaitForChild('InputBox')
4local 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.

01plr:GetMouse().Move:connect(function()
02 
03local Target = plr:GetMouse().Target
04 
05if Target == nil then OnHoverFrame.Visible = false; return end -- Mouse isn't hovering a part
06 
07if Target.Parent == workspace then OnHoverFrame.Visible = false; return end -- It's just a normal part, not part of a character for sure
08 
09local TargetPlayer = game:GetService('Players'):GetPlayerFromCharacter(Target.Parent)
10 
11if TargetPlayer==nil then OnHoverFrame.Visible = false; return end -- Not part of a player's character
12 
13local TargetPlayersMessage = TargetPlayer:WaitForChild('PlayerGui'):WaitForChild('MsgInputGui'):WaitForChild('MainFrame'):WaitForChild('InputBox').Text -- Get the target player's message
14 
15MsgLabel.Text = TargetPlayersMessage
16 
17OnHoverFrame.Visible = true
18 
19end)

And done! Final script:

01local plr = game:GetService('Players').LocalPlayer
02local PlayerGui = game:GetService('Players').LocalPlayer:WaitForChild('PlayerGui') -- Even if script.Parent isn't the player's PlayerGui, it can find it
03local InputGui = PlayerGui:WaitForChild('MsgInputGui')
04local OnHoverGui = PlayerGui:WaitForChild('OnHoverGui')
05 
06local InputFrame = InputGui:WaitForChild('MainFrame')
07local OnHoverFrame = OnHoverGui:WaitForChild('MainFrame')
08local InputBox = InputFrame:WaitForChild('InputBox')
09local MsgLabel = OnHoverFrame:WaitForChild('MsgLabel')
10 
11plr:GetMouse().Move:connect(function()
12 
13local Target = plr:GetMouse().Target
14 
15if Target == nil then OnHoverFrame.Visible = false; return end -- Mouse isn't hovering a part
View all 29 lines...

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.

Ad

Answer this question