Help with making gui appear when you open dialog?

So I am currently trying to make gui appear when the activate dialog, but there is a problem, Every tutorial I found, makes the gui appear when you click a dialog choise, not the actual dialog. Is there a way to do this? This is what I have so far:

Screenshot 2021-05-29 091823

script.Parent.DialogChoiceSelected:Connect(function(plr,dialog)
	local event = game.ReplicatedStorage.DialogEvent
	event:FireClient(plr)
end)

I am not trying to make a shop, I am trying to make a gui button appear with modal enabled so the mouse can move in first person so you can actually select dialog choices because the game is in first person only, If there is another way to do that, please let me know.

2 Likes

Just disable movement and temporarily set the camera mode to something else whilst having the conversation

1 Like

But how do I do that? I can’t find a single way to make anything happen, even printing something, when you first engage the conversation. Like this:

As you can see, I can’t continue the conversation in first person, but of course I allowed third person for testing.

Also the movement is always 0, because I am making mata nui online game in roblox.

1 Like

there are values you can manipulate within the player called CameraMaxZoomDistance and CameraMinZoomDistance, along with changing camera mode you should be able to move your mouse around freely

You can unlock the mouse like this:

  1. Create a UI.
  2. Add a TextButton.
  3. Set the TextButton Size to UDim2.new(0,0,0,0)
  4. When you want to unlock the mouse, change the TextButton’s Modal to TRUE
    If you want to lock again the mouse, set the TextButton’s Modal to FALSE

I use this to unlock mouse in my games.

I know about those values, that is how I made the game first person, but how am I supposed to enable it? Every tutorial I found, had it so when the respond to the initial prompt, not when you click the big bubble that starts the conversation, the gui and other stuff appear. I can’t respond to the initial prompt, if I am in first person, but I can’t change that if I can’t do anything when I click the bubble.

Add a local script inside starterplayerscripts:

local event = game.ReplicatedStorage.DialogEvent

event.OnClientEvent:Connect(function(plr,dialog)
	-- Do something...
end)

When you fire a Remote to the client, you can do this
:FireClient(player,true) or with false
and in a LocalScript inside the gui, when
.OnClientEvent:Connect(function(value)
Do this:
script.Parent.TextLabel.Modal = value

So i’ll look like this.

game.ReplicatedStorage.DialogEvent.OnClientEvent:Connect(function(value)
	script.Parent.TextLabel.Modal = value
end)

I basically already have that, but I can’t start the event because I can’t find a way to for example, print “hi”. I want the hi to print only when the bubble that makes the character say it’s initial prompt to be clicked. If I replace hi with starting the events, I basically am done, but I can’t find a way to do that.

When that happens, when I press that button, I want the event to start.

Also here is the gui code:

local event = game.ReplicatedStorage.DialogEvent
local event2 = game.ReplicatedStorage.CloseDialogEvent
event.OnClientEvent:Connect(function()
	script.Parent.Dialog.Visible = true
end)
event2.OnClientEvent:Connect(function()
	script.Parent.Dialog.Visible = false
end)

I made something incredibly similar to this for the movement system, and it works perfectly.

Well, you can actually do check if Dialog haves “InUse” at true in a LocalScript.
Something like this

local dialog = workspace.NobleHuna.Dialog
seat:GetPropertyChangedSignal("InUse"):Connect(function()
	script.Parent.TextLabel.Modal = dialog.InUse		
end)
1 Like

what is seat? Also this is where the NobleNuna actually is lol:

Screenshot 2021-05-29 095618

But more importantly, I am planning on making many NPCs with different dialogs, Is there a way to do this without making a ton of scripts or cluttering a single script?

bruh i setted seat, because i am doing something with seats, change it to dialog.
also change dialog value to your thing

1 Like

You can do workspace:GetDescendants() and check if one dialog is InUse, then set.

1 Like

I tried the workspace:GetDescendants method, and this happened:

Screenshot 2021-05-29 101201

Code:

local dialog = workspace:GetDescendants()
for i, v in pairs(dialog) do
	if i:IsA("Dialog") and i.Name == "TohungaDialog" then
	 	i:GetPropertyChangedSignal("InUse"):Connect(function()
			script.Parent.Dialog.Modal = i.InUse		
		end)
	end	
end	

Probably me being dumb but it doesn’t work.

Doesn’t work.

you are trying to run :IsA() on a number, try to run :IsA() on v

1 Like

knew it

I’ve quit studio for too long!

EDIT: doesn’t work

local dialog = workspace:GetDescendants()
for i, v in pairs(dialog) do
	if v:IsA("Dialog") and v.Name == "TohungaDialog" then
	 	v:GetPropertyChangedSignal("InUse"):Connect(function()
			script.Parent.Dialog.Modal = v.InUse		
		end)
	end	
end	

no errors

I would personally do something like this:

for _, Dialog in pairs(workspace:GetDescendants()) do
	if Dialog:IsA("Dialog") and Dialog.Name == "TohungaDialog" then
	 	Dialog:GetPropertyChangedSignal("InUse"):Connect(function()
	 	 	script.Parent.Dialog.Modal = Dialog.InUse
	 	end)
	end
end

I don’t think Modal is a property of a Dialog, I think it is a property of gui buttons

1 Like

the text button is named dialog lol.

It also doesn’t work for some reason.

game is singleplayer

Actually, I don’t understand how it works.

local function DialogUsed(Dialog, Value)
	script.Parent.Dialog.Modal =
end

for _, Dialog in pairs(workspace:GetDescendants()) do
	if Dialog:IsA("Dialog") and Dialog.Name == "TohungaDialog" then
		Dialog:GetPropertyChangedSignal("InUse"):Connect(DialogUsed)
	end
end

What am I supposed to right there?

oh my code works, I just forgot to turn visible on sorry!

I made a mistake above, I edited my script, that should work ig, I usually use separate functions but reading further into this post you didn’t need much, only modal being toggled I’ve seen by reading, I made my function shorter

using separate functions will sometimes make it more readable when using tons of multiple lines

1 Like