I'm making a mini basketball game project and I want to add guarding so I made a script for the animation to play but why isn't it stopping?? Please help.
local plr = game.Players.LocalPlayer
local chr = plr.Character
local humanoid = chr.Humanoid
local uis = game:GetService("UserInputService")
local animid = 'rbxassetid://3312318024'
local db = true
uis.InputBegan:connect(function(input,gpe)
if gpe then
return
end
if input.KeyCode == Enum.KeyCode.G then
local anim = Instance.new("Animation")
anim.AnimationId = animid
local LoadAnimation = humanoid:LoadAnimation(anim)
LoadAnimation:Play()
end
end)
uis.InputEnded:connect(function(input,gpe)
if gpe then
return
end
if input.KeyCode == Enum.KeyCode.G then
db = false
local anim = Instance.new("Animation")
anim.AnimationId = animid
local LoadAnimation = humanoid:LoadAnimation(anim)
anim:Destroy()
db = true
end
end)

1 comment
Best Game Ever!