Hello all! I'm having an issue with a script I'm making.. To give you some insight, I want it when I press "LeftShift" it plays an animation, BUT it needs to check if the tool is equipped(M4), if the tool isn't equipped, then when you press Left Shift nothing happens. This is a Local Script inside of StarterCharacterScripts:
local player = game.Players.LocalPlayer
local character = player.Character or script.Parent
local Humanoid = character.Humanoid
local tool = game.StarterPack.M4
local UserInputService = game:GetService('UserInputService')
local AnimationID = 'rbxassetid://033456263'
local Key = "LeftShift"
UserInputService.InputBegan:Connect(function(Input, IsTyping)
if IsTyping then return end
if Input.KeyCode == Enum.KeyCode[Key] then
local Animation = Instance.new("Animation")
Animation.AnimationId = AnimationID
local LoadAnimation = Humanoid:LoadAnimation(Animation)
tool.Equipped:Connect(function()
LoadAnimation:Play()
end)
end
end)

3 comments
When you press Left Shift, it listens to Equipped; only when that fires it will play the animation. Instead, check if the tool is equipped when you press Left Shift, then play the animation.
Ok, thanks I'll try that.
Didn't work..