I have a script that plays a sound, among other things, when you press a key. What I want to know is to how you make the sound stop when you let go of the key? Did I mess up?
repeat wait() until game.Players.LocalPlayer
mouse = game.Players.LocalPlayer:GetMouse()
mouse.KeyDown:connect(function (key) -- Run function
key = string.lower(key)
if string.byte(key) == 48 then
script.Parent.ImageTransparency = 0
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 95
game.Workspace.Sound3:Play()
end
end)
mouse.KeyUp:connect(function(key)
key = string.lower(key)
if string.byte(key) == 48 then
script.Parent.ImageTransparency = 1
game.Players.LocalPlayer.Character.Humanoid.Walkspeed = 40
game.Workspace.Sound3:Stop()
end
end)
*** Help me***

1 comment
Don't use KeyDown or KeyUp.