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

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

Asked by 2 years ago
Edited 2 years ago

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

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

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

0
It didn't work. Nothing happened. No errors. Wackyquacked 2 — 2y
0
It didn't work. Nothing happened. No errors. Wackyquacked 2 — 2y
0
Could you add me on discord? I'm a little confused on why it didn't work. LoxiGoose#9553 DocGooseYT 110 — 2y
Ad

Answer this question