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

Keybind Weapon Animation Won't Play?

Asked by 5 years ago
Edited 5 years ago

Hey I am trying to make it so when I press "F" my character will play a certain animation for the tool. as of now i put the following code into the tool itself, i'm thinking maybe it's better in the StarterCharacterScripts?

is there anything wrong with the following?

repeat wait() until game.Players.LocalPlayer~=nil
local Bussy = false
local LastSlash = tick()
local Player = game.Players.LocalPlayer
local Character = Player.Character
local Humanoid = Character:WaitForChild("Humanoid")
wait(1)
local Animations = {
["Idle"] = nil
}
local Animations = {
["Flip"] = nil
}
script.Parent.Equipped:Connect(function()
Animations.Idle = Character.Humanoid:LoadAnimation(script.Parent.Idle)
Animations.Walk = Character.Humanoid:LoadAnimation(script.Parent.Walk)
Animations.Flip = Character.Humanoid:LoadAnimation(script.Parent.Flip)
Animations.Idle:Play()
Animations.Flip:Play()
end)
script.Parent.Unequipped:Connect(function()
for _,Animation in pairs(Animations) do
Animation:Stop()
end
end)
script.Parent.Activated:Connect(function()
if not Bussy then 
Bussy = true 
end 
end)
game:GetService("UserInputService").InputBegan:connect(function(KeyInput)
if KeyInput.KeyCode == Enum.KeyCode.F then
Animations.Flip:Play()
wait(1)
Animations.Flip:Stop()
 end
  end)

Answer this question