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

Key Binding assistance?

Asked by 10 years ago

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.

0
You're using "j:Play()". Try "k:Play()". SlickPwner 534 — 10y

1 answer

Log in to vote
0
Answered by 10 years ago

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)
0
And that'd work? MATTY1319 10 — 10y
Ad

Answer this question