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

Making a ScreenGUI Dialog Textbox?

Asked by 6 years ago
Edited 6 years ago

I want to make dialog for my in-game characters that will be a textbox at the bottom of the screen. I've tried so many scripts and I can't manage to get them to work. Can I get some help please? I'm so tired of trying to make one because I suck at script.

my stupid script

debounce = false
function OnClicked()
    local Dialog = game.StarterGui.Dialog.Dialog
    Dialog.Visible = true
    local DialogName = game.StarterGui.Dialog.PersonsName
    DialogName.Visible = true
end

script.Parent.ClickDetector.MouseClick:connect(OnClicked)

There is my attempt I made. I've made several other attempts at doing this.

3 answers

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

The main problem here is that you are using StarterGui. It is not where the players store their currently-viewing GUIs - it is a place where GUIs get cloned from to be put into the players' PlayerGui.

You will find that if you respawn, you should see the dialog box.

As well as that, the GUI part is simply not a job for a server-side Script. Instead, use two different scripts - a LocalScript and a normal Script.

Normal Script (AKA server-side Script):

local Gui = script.DialogGui -- put the ScreenGui inside the server-side script

script.Parent.ClickDetector.MouseClick:Connect(function(PlayerWhoClicked)
    local Clone = Gui:Clone() -- makes a copy of the gui
    Clone.Parent = PlayerWhoClicked.PlayerGui -- 'pastes' it into the player's PlayerGui
end)

LocalScript:

local Gui = script.Parent -- say this was a LocalScript inside the ScreenGui
local Dialog = Gui.Dialog
local PersonsName = Dialog.PersonsName
local Player = game.Players.LocalPlayer -- only works in LocalScripts

-- don't need to wait for any events since the script runs after it gets cloned by the server-side script
PersonsName.Text = Player.Name
-- you should not need to make PersonsName visible since setting the visibility of something holding other things also makes the things inside it the same visibility
Dialog.Visible = true
-- you do not really need to make it toggle visibility for something this simple, since it is meant to be visible when it comes into existence anyway

-- closes the dialog after 5 seconds
wait(5)
Gui:Destroy()

Hope I helped!

~TDP

0
Thank you so much! winner208 74 — 6y
Ad
Log in to vote
2
Answered by 6 years ago

Please read the community guidelines before you make a question next time. This post applies to #4 in General Website Rules, which says that ScriptingHelpers are a help site, not a request site. Provide some sort of evidence that you tried to do this yourself and aren't asking for it to be done for you and I'm confident that many people would be more than happy to help you.

0
kill me winner208 74 — 6y
0
You can try looking at wiki.roblox.com. It should help you quite a bit while learning to script. I can't legally kill you. SchonATL 15 — 6y
0
alright winner208 74 — 6y
Log in to vote
0
Answered by
phxtn 154
6 years ago
Edited 6 years ago

Use this in a local script

debounce = false
function OnClicked()
    local Dialog = game.Players.LocalPlayer.PlayerGUI.Dialog.Dialog
    Dialog.Visible = true
    local DialogName = game.Players.LocalPlayer.PlayerGUI.Dialog.PersonsName
    DialogName.Visible = true
end

script.Parent.ClickDetector.MouseClick:connect(OnClicked)
0
"LocalPlayer" can be used in LocalScripts, but on Studio, it will only affect "Player1" Rawblocky 217 — 6y

Answer this question