Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Does anyone know how to make it so a dialogue option kicks a player from the game?

I'm making an npc for my game and I'm trying to make it so the player will be kicked if they choose a mean answer, I'm really new to scripting so if someone could just tell me the script that would help a lot! Tysm in advance

1 comment

0

I wouldn't suggest you to kick player's if they choose a reply that you have made as an option. Many people like to try all dialogue replies if possible to know what they do. But since you asked; https://developer.roblox.com/en-us/api-reference/function/Player/Kick

1 answer

Hello,

You need to use DialogChoiceSelected.

Please read and understand what im about to tell you.

local Player = Instance.new("Player") -- Player function

workspace.Dialog.DialogChoiceSelected:connect(function(player,choice) --Make sure to say instead of "workspace" where the NPC actually is, if the NPC is located in Workspace, then leave the script like that.
	if choice.Name == "No, you suck" then --Change "No" with what the name of the Dialog is
		Player:Kick("Thats what you get for saying I suck")
	elseif choice.Name == "Yes, you're the best player ever" then --Change "Yes, you're the best player ever" To the name of the dialog choice
		player.Character.Humanoid.Health = 1000
	end
end)

Please reply to me when you have any questions, when the script isn't working, etc.

This discussion is preserved as it was. New answers, comments, and votes are closed.