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