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

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

Asked by 8 years ago

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

Closed as Not Constructive by M39a9am3R

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

1 answer

Log in to vote
0
Answered by 8 years ago
--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.
0
Oh, and make sure the looped property of the sound is false. ChrisCoder 0 — 8y
0
Or just add sound.Looped = false. ChrisCoder 0 — 8y
Ad