Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do I perform a function when a dialog choice is selected?

Asked by 6 years ago
Edited 6 years ago

I want a player who selects a dialog choice to be kicked once they select that choice, but I have no clue where to start. I've been searching online for a while but none of the codes seem to work.

local Dialog = script.Parent

Dialog.DialogChoiceSelected:connect(function(Player, Choice)
        game.Players.LocalPlayer:Kick()
end)
0
Show us your code. It gives us a better idea on how we can help you. starlebVerse 685 — 6y
0
Is that in a localscript? M9_Sigma 35 — 6y
0
still doesn't not work lolkid007 43 — 6y
0
chat service JelliedBanana 0 — 5y

1 answer

Log in to vote
1
Answered by 6 years ago

Tested your script. I think it's not working because LocalScripts don't run under dialogs. They only run under (from the wiki):

  • Player Backpacks
  • Player Characters
  • StarterGui/PlayerGui
  • PlayerScripts
  • ReplicatedFirst

Or maybe DialogChoiceSelected doesn't work under local scripts but I think it's because of where you parent it.

This is actually easy to fix. Use a server (regular) script, and since DialogChoiceSelected returns the player, we can use that to find and kick the player.

Here's what your script should look like :

local Dialog = script.Parent

Dialog.DialogChoiceSelected:Connect(function(Player, Choice)
    Player:Kick()
end)

-- Note this kicks the player using the dialog when picking ANY choice

Hope this helps!

0
this does not work for me... KoolGamer3000YT 0 — 4y
0
^ Hi! This answer is a bit outdated now as DialogChoiceSelected now only works in local scripts/clientsided, so please use that instead. More info here: https://developer.roblox.com/en-us/api-reference/event/Dialog/DialogChoiceSelected User#20279 0 — 4y
Ad

Answer this question