Is their a way to check if a player picked a Dialog Choice?

Hello! So I’m trying to make a Wizard NPC for my game Jawks! A ROBLXO Puzzle game, When the Player Picks the “I want the Potion!” then a potion will spawn!

Is This Possible?

2 Likes

Yes it’s possible, you would do something like this:

local Dialog = yourpathtothedialog
Dialog.DialogChoiceSelected:Connect(function(Player,Choice)
if Choice.Name == “TheNameOfTheDialog” then
–give the potion to the player
end
end)

2 Likes

So something like this?

local SpeedPotion = game.ReplicatedStorage.SpeedPotion

local Dialog = script.Parent.Parent
Dialog.DialogChoiceSelected:Connect(function(Player,Choice)
	if Choice.Name == "GivePotion" then
		local SpeedPotionClone = SpeedPotion:Clone()
		SpeedPotionClone.Name = "Speed Potion"
		SpeedPotionClone.Parent = game.Workspace
		SpeedPotionClone.Position = Vector3.new(-10.47, 27, -255.549)
	else
		if Choice.Name == "DontGivePotion" then
			return
		end
	end
end)
5 Likes

Yes ,and make sure it is in a local script
Edit: also make sure the local script is in StarterPlayer.StarterPlayerScripts or else it won’t work

4 Likes

I made it a local script and everything but it didn’t work, the potion doesn’t generate into the world at all, and the script for some reason doesn’t work

have you placed the script into starterplayerscripts

1 Like

Just Noticed your edit!

yes I have and re-made the path.

1 Like

It works thanks B>

now the wizard can officially give players potions!

1 Like

Yes, this is possible.

How I would go about this:

  1. Adding 2 bool values to the GUI
  2. Scripting the corresponding bool value to make it true when the player clicks either of the option GUIs
  3. Then making a script to do what ever I want when the corresponding bool value is true.

( You could also make an event, but I personally don’t know how to do this. )

As for the script that does stuff for when the bool value is true, you could make it:

  • Play a sound effect
  • Give a potion / tool
  • Enable particle effects
  • Play an animation
    etc.

Hope this helps. :>

1 Like

Oh no! I was using the ROBLOX Dialog prompt and stuff! I know how to do this with UI anyway!

1 Like

I know it’s been a year but along with the if Choice.Name == "GivePotion" then you should put an and statement for if Choice.Name == "GivePotion" and Player == game.Players.LocalPlayer then otherwise the event will fire if ANYONE in the server selects that dialog.

3 Likes

Thanks, but you could have also messaged me that.

1 Like