Help with making gui appear when you open dialog?

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

It works! If you want to see the progress on this game, you can find it here.

Thank you!

1 Like

Well, I was AFK, hope your game works fine! I’ll see the progress.

1 Like

I made a new devlog for this game here.

I can’t wait for the game to be finished!

1 Like