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.
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
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.
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)