I need help on scripting this

I have no experience in scripting and have little idea how to make something like this.
my plan is when the player answers yes to a question from a npc, (using the dialog system)

Capture
(not sure why i added this)

a transparent wall will delete itself and let the player go through a door.
any idea how i would do this?

I don’t think you can do this with Dialog instances, you would have to make a new system from scratch

1 Like

I kinda have a thought what it would be:

local players = game.Players:GetPlayers()
if player.userdialog = yes then
game.workspace.invisiblewall.Transparent = 1

I know this code won’t work, but its a start.

oops lol I meant

local player = game.Player:GetPlayer()
if player.userdialog.yes then
	game.workspace.invisiblewall.CanCollide = false
end```
local DialogLocation = nil --Define Dialog Location here
local UnveilingDialogOption = nil --Define the Location of the DialogChoice that would open a wall or whatever you want it to do.

DialogLocation.DialogChoiceSelected:connect(function(Plr, DialogOption)
	if DialogOption == UnveilingDialogOption then
		--Do stuff here, such as remove the wall or whatever you want it to do. 
		--You can also make it do certain things specifically for the player by utilizing the Plr variable.
		--If you want the wall to be removed/whatever other changes to effect that player ONLY, put this in a LocalScript.
	end
end)

Oh sorry nvm then I didn’t know there was a way to do that with dialog lol my bad

And here is a link to the event in the documentation

https://developer.roblox.com/en-us/api-reference/event/Dialog/DialogChoiceSelected

2 Likes

thanks!

character limit text thing

kinda dumb question, but where can i find what the plr is?
my edited script

local DialogLocation = game.Workspace.shopkeeper.Head.Dialog --Define Dialog Location here
local UnveilingDialogOption = game.Workspace.shopkeeper.Head.Dialog.DialogChoice.DialogChoice2.DialogChoice3 --Define the Location of the DialogChoice that would open a wall or whatever you want it to do.

DialogLocation.DialogChoiceSelected:connect(function(DialogChoice3, yes)
	if DialogLocation == UnveilingDialogOption then
		game.Workspace.WallTransparent.CanCollide = false	--Do stuff here, such as remove the wall or whatever you want it to do. 
		--You can also make it do certain things specifically for the player by utilizing the Plr variable.
		--If you want the wall to be removed/whatever other changes to effect that player ONLY, put this in a LocalScript.
	end
end)

@HeyWhatsHisFace

I tried using printing and it keeps failing on line 3, im not sure why.

DialogLocation.DialogChoiceSelected:connect(function(Plr, DialogOption)
This is the connection to the event. The event fires 2 variables along side it, which we can rename ourselves if we want by writing them within the function parameters. Here, I named them Plr and DialogOption. The Player Instance will always be the first parameter and the DialogOption Instance will always be the second option. The event parameters are listed in the documentation here.

In your edit, you have the Player Instance defined to the variable DialogChoice3 and the DialogChoice defined to the variable yes.

I accidently wrote DialogLocation instead of DialogOption, so I edited the highlighted line to fix my typo, sorry! This checks to make sure that the selected dialog option (fired by the event) matches the option you defined earlier that you want to perform the action.
(game.Workspace.shopkeeper.Head.Dialog.DialogChoice.DialogChoice2.DialogChoice3)

This is what it should look like all together.

local DialogLocation = game.Workspace.shopkeeper.Head.Dialog --Define Dialog Location here
local UnveilingDialogOption = game.Workspace.shopkeeper.Head.Dialog.DialogChoice.DialogChoice2.DialogChoice3 --Define the Location of the DialogChoice that would open a wall or whatever you want it to do.

DialogLocation.DialogChoiceSelected:connect(function(Plr, DialogOption) --The event provides us two parameters which we have defined as "Plr" and "DialogOption"
	if DialogOption == UnveilingDialogOption then --Checks to make sure the DialogOption fired from the event DialogChoiceSelected matches the UnveilingDialogOption.
		game.Workspace.WallTransparent.CanCollide = false	--Do stuff here, such as remove the wall or whatever you want it to do. 
		--You can also make it do certain things specifically for the player by utilizing the Plr variable.
		--If you want the wall to be removed/whatever other changes to effect that player ONLY, put this in a LocalScript.
	end
end)
1 Like