Hi, I wrote a script for a slide tackle, it checks if the player that touches them is sliding, only then it play the tackled animation.
It works. When I slide, it gets tackled, but if I enter the hitbox without sliding and then when I try again with sliding enabled, it doesn’t get tackled and doesn’t repeat the code.
Script:
local playing = false
local an = script.Parent.Parent.Animation
local anim = script.Parent.Parent.Humanoid:LoadAnimation(an)
script.Parent.Touched:Connect(function(hit)
if playing == false then
playing = true
if hit.Parent.Name == "Dummy" then return end
if hit.Parent:FindFirstChild("Humanoid") then
print("isPlayer")
if hit.Parent:FindFirstChild("isSliding") then
print("isSliding")
if hit.Parent.isSliding.Value == false then return end
if hit.Parent.isSliding.Value == true then
print("player is sliding")
anim:Play()
anim.Ended:Wait()
playing = false
end
end
end
end
end)