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

Dialog shout on KeyDown?

Asked by 8 years ago

I want my character to shout: Naruto Power: Shuriken, but it doesnt work. In other words, I want a dialog shout out of my head saying those words. But i dont want to click on the question mark, I want it to say it as I hit "p".

player = game.Players.LocalPlayer
mouse = player:GetMouse()

mouse.KeyDown:connect(function(key)
    if key == "p" and player.Character then
        local chat = Instance.new("Dialog", player.Character.Head)
        chat.Name = "Power"
        chat.InitialPrompt = "Naruto Power: Shuriken"
        chat.InUse = true
    end
end)
0
Are you using a HopperBin? funyun 958 — 8y

2 answers

Log in to vote
0
Answered by
AIphanium 124
5 years ago
Edited 5 years ago

There is something that helps for that, known as TriggerDistance and ConversationDistance, add this beneath the Chat line.

chat.TriggerDistance = 400
chat.ConversationDistance = 999
chat.GoodbyeChoiceActive = false

Oh, and also, make sure to remove the chat after awhile, so it won't spam Shurikens over your head.

wait(5)
chat:Remove()

Hope it helps!

Ad
Log in to vote
-1
Answered by
funyun 958 Moderation Voter
8 years ago

Assuming you're using a HopperBin:

player = game.Players.LocalPlayer

function onKeyDown(key)
    if key == "p" and player.Character then
        game:GetService("Chat"):Chat(player.Character, "Naruto Power: Shuriken", "Red")
    end
end

function onSelected(mouse)
    mouse.KeyDown:connect(onKeyDown)
end

script.Parent.Selected:connect(onSelected)

If you aren't:

player = game.Players.LocalPlayer
mouse = player:GetMouse()

mouse.KeyDown:connect(function(key)
    if key == "p" and player.Character then
        game:GetService("Chat"):Chat(player.Character, "Naruto Power: Shuriken", "Red")
    end
end)

Answer this question