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

How do I kick someone when they pick a dialog option?

Hello. I have been trying to make a story game and I want it so that when you pick the option "infected", it pauses for a bit so you can read what the character says and then kicks you, displaying the ending. I have been trying to make it work, but it still malfunctions. When I click the dialog option, the script does not run. Please help! My code:

script.Parent.DialogChoiceSelected:connect(function(player, choice)
	if (choice == script.Parent.infected) then
		player:Kick("You got the 'Infected' Ending")
	end
end)

(btw the script is in the dialog object)

1 answer

DialogChoiceSelected only fires locally, I would use a local script and remote event to detect the choice being selected and send info over to the server.

EX:

--Local Script code

"Dialog here".DialogChoiceSelected:Connect(function(choice)
	if choice == "Dialog here".infected then
		game.ReplicatedStorage.RemoteEvent:FireServer("Infected")
	end
end)

--Normal Script code

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(plr, choice)
	if choice == "Infected" then
		plr:Kick("You got the 'Infected' Ending")
	end
end)

That's how I would write it but it's entirely up to you on how you wish to write the code. (remember, local script and remote event!)

3 comments

0

It didn't work. Nothing happened. No errors.

0

It didn't work. Nothing happened. No errors.

0

Could you add me on discord? I'm a little confused on why it didn't work. LoxiGoose#9553

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