I’m struggling with scripting for ages. What I want to achieve is to play a sound when holding a shift key and I seem to be very struggling to do it by myself. If anyone know how to do it, would you mind helping me getting the script working. I would be very appreciated! Thank you!
local UserInputService = game:GetService("UserInputService")
UserInputService.InputBegan:Connect(function(input,isTyping)
if input.KeyCode == Enum.KeyCode.LeftShift or input.KeyCode == Enum.KeyCode.RightShift then
YourSound:Play()
end
end)
--me just used free model script: sprint script you may find it in ToolBox. (Place in StarterGui
repeat wait() until game.Players.LocalPlayer
m = game.Players.LocalPlayer:GetMouse()
m.KeyDown:connect(function(key)--Key is holding (Shift)
if key == "0" then -- 0 is Shift Button
script.Parent.Sound:Play()--change Sound to your sound name
end
end)
m.KeyUp:connect(function(key)--Key is not more holding (Shift)
if key == "0" then
script.Parent.Sound:Stop()
end
end)