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

How would you make a sound play when you press a key (Shift)?

How would I be able to make a certain sound id play (Boosting).. When I press a key(shift)?

1 answer

✓ Accepted answer
--Make sure this is a local script. Inside of backpack.
--By ChrisCoder.
local player = game.Players.LocalPlayer
local mouse  = player:GetMouse()
local db = false -- debounce.
wait(2)
local sound = Instance.new("Sound", player.Character.Torso)
repeat wait() until player and player.Character
 sound.SoundId = "rbxassetid://" --Your id.
mouse.KeyDown:connect(function(key)
--47 right shift, 48 left shift.
if key:btye() == "47" then
if db == false then
db = true
sound.Volume = 1
sound:Play()
wait(2) -- time until you can boost or whatever again c;
db = false
end
end
end)
--If anything is broken or dosen't work pm me.

2 comments

0

Oh, and make sure the looped property of the sound is false.

0

Or just add sound.Looped = false.

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