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)
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!)