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

Dialog shout on KeyDown?

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)

1 comment

0

Are you using a HopperBin?

2 answers

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!

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)

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