Making a dialoge system, don't know how to go about it

so I am trying to make a dialoge system, but nothing i do works. I am new to gui scripting and just scripting in general so please bare with me.

so the idea is that i want there to be a gui around the bottom of the screen with dialoge, then once the player clicks anywhere on the dialoge gui the text changes pretty simple, but i don’t know how to get this done.
Screenshot 2024-05-01 165950
this is my gui right now. I have tried putting a ClickDetector inside DialogeGui and making code for that, but that doesn’t work.

this is the code that i used when a ClickDetector was in DialogueGui

game.StarterGui.DialogueGui.ClickDetector.MouseClick:Connect(function(Player)
	print("clicked")
end)
1 Like

You can accomplish this by placing a button within the frame, adjusting the button’s text and background transparency to 1, and resizing the button to match the frame’s dimensions.

From there…

local button = gui.DialogueButton -- change to your button
-- Connect the button's MouseButton1Click event
button.MouseButton1Click:Connect(function()
    print("Button clicked")
    -- Add your code here to change the text or progress the dialogue
end)

ClickDetector is for 3D objects, as far as I am aware, they do not work for GUIs.

Have you tried looking at tutorials or referencing models from the tool box to see how they did it?

1 Like

thank you, but this isn’t working for me. I tried it and i agree that it should work but it is not working for me. I added a button over the text but it isn’t printing anything.

the only reason I made a dev forum post about it was because I wasn’t able to find a tutorial on how to do this, if I had I would have followed that.

This doesn’t work because you are actually referencing the startergui service, anything in startergui is replicated to a player’s playergui. The actual object in startergui is not used for what the player actually sees on their screen. It’s the player gui. Here’s an example:

local player = game.Players.LocalPlayer
local playergui = player.PlayerGui
local textbutton = playergui:WaitForChild("ScreenGui").TextButton -- screengui wouldn't have loaded in yet
textbutton.Activated:Connect(function()
print("Activated")
end)

Clickdetectors don’t work on guis aswell by the way, you can just click on it its built in function.

yes this makes sense, I remember that anything in startergui gets replicated to each player when they join the game, thank you

Yeah no problem, also the clickdetector wouldn’t have worked anyway though… Just click on the text button it’s a built in feature. Only textbuttons have the default feature of being clickable, so add a textbutton.

yeah, i forgot that i could make it invisible… I also kinda didn’t know the syntax…

I’d recommend putting a TextButton inside the frame, make its size the whole frame, to ensure the screen is actually clickable.
ClickDetectors do not work in GUI. Try communicating with the TextButton with TextButton.MouseButton1Click:Connect…

Here you go:

TextButton.Activated -- fires once the player clicks on the button

Also, for your current script you can just do script.Parent since the script is parented in the startergui. But if you have a local script outside of startergui you would have to reference the playergui. Also here’s how to make a button invisible:

TextButton.Visible = false -- as easy as pieee

You can look up the syntax here: TextButton | Documentation - Roblox Creator Hub

this is great, but obviously I have to get an error.it says attempting to index nil with “PlayerGui”

Are you doing this in a serverscript? Should be a local one.

Oh sorry, I thought the local script was already inside the PlayerGUI so it doesn’t need to wait for the GUI to load, as it’ll load with it. If the script isn’t in the GUI try calling the PlayerGui with WaitForChild.
If it isn’t working, make sure your script is Local, GUI works only on the Local Side

You can also just do script.Parent if your script is parented to startergui.

yes, i’m doing this in a server script

NOOOO, do it in a local script, game.Players.LocalPlayer is only possible on local scripts.

tbh, I used a tutorial, and that’s what they said to do