Dialog choice to make ui visible

I want to make a dialog choice to makes a ui visible. The problem is that it prints out the gun but it still wont make it visible. This is a local script because it doesn’t work on server scripts. Here is a vid and the code

local dialog = game.Workspace.Cashier.Head.Dialog

dialog.DialogChoiceSelected:Connect(function(player, choice)
	print(choice)
	if choice == "gun" then
		script.Parent.Visible = true
	end
end)


can you check the explorer to see if the ui visible property actually changes before and after

It doesn’t change and i checked inside playergui not starter gui

i also added an else and and make it print wrong if it is else and it prints wrong even though they are the exact same

maybe they arent the exact same, try print(#choice) i think it gives the character count and it should be 3

what you said didint work so i first had to change the choice to a string butafter i did that it printed 3

so it prints 3 and also says it doesnt match?

:+1: yes correct :+1: :+1: :+1: :+1: :+1:

can you print type(choice) to see what it outputs, should be string

Really simple fix!
You’re using an if statement to detect if there is a string named “gun”, however, this is not how you utilize it.
Rather, you will detect if the user selects the correct option.

local dialog = game.Workspace.Cashier.Head.Dialog
local guiFrame = script.Parent

dialog.DialogChoiceSelected:Connect(function(player, choice)
	if choice == dialog["Rent A Gun"] then
		script.Parent.Visible = true
	end
end)

Screenshot 2023-04-21 at 10.37.16 PM

Your explorer setup should look something like this.

i fixed it i just turned the choice into a string with tostring()

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.