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

Key Binding assistance?

How would I key-bind an audio file to a certain letter?

Currently I have:

k = Workspace.Present Plr = script.Parent.Parent.Parent Mouse = Plr:GetMouse() Mouse.KeyDown:connect(function(Key) if Key:lower() == "j" then j:Play() end end)

Is there a way to make this work? If so, please help.

The audio file Workspace.Present has the audio ID and is in the correct place as I put it but it wont play.

1 comment

0

You're using "j:Play()". Try "k:Play()".

1 answer

You need to use a LocalScript to use the Player:GetMouse method. Here's an example:

local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()

local sound = game.Workspace.Sound -- Change this to the path to your sound

mouse.KeyDown:connect(function(key)
	if key:lower() == "j" then
		sound:Play()
	end
end)

1 comment

0

And that'd work?

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