Animation still play when I tween

Hey,

I need your help because when I tween the HumanoidRootPart the animation still does play. I want stop all animation and play my own animation but it doesnt seem work, so how can I fix this?

Here is a video for visualize the problem:

https://vimeo.com/manage/videos/503795286

and here is the script:

local rp = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local Debris = game:GetService("Debris")
local attack = rp:WaitForChild("attack")
local Attackonwall = Instance.new("Animation")
Attackonwall.AnimationId = "rbxassetid://6253916213"

    attack.OnServerEvent:Connect(function(player)
    	local character = player.Character
    	local humanoidRP = character:WaitForChild("HumanoidRootPart")
    	local Humanoid = character:WaitForChild("Humanoid")
    	local RightHand = character:WaitForChild("RightHand")

    	local sword = Instance.new("Part")
    	sword.FormFactor = "Custom"
    	sword.Shape = Enum.PartType.Block
    	sword.Material = "Neon"
    	sword.Name = "RedRayForAttack"
    	sword.CFrame = humanoidRP.CFrame * CFrame.new(0,-1,-4)
    	sword.Anchored = true
    	sword.CanCollide = false	
    	sword.Parent = game.Workspace
    	
    	sword.Touched:Connect(function(hitted)
    		local HumanoidRootPart = hitted.Parent:FindFirstChild("HumanoidRootPart")
    		local HumanoidNPC = hitted.Parent:FindFirstChild("Humanoid")
    		local EHumanoidP = HumanoidRootPart.Position
    		local AniamtionPlay = HumanoidNPC:LoadAnimation(Attackonwall)
    		local goal = {}
    		goal.CFrame = CFrame.new(game.Workspace.checkl.Position)
    		local tweenPlay = TweenService:Create(HumanoidRootPart, TweenInfo.new(0.1), goal):Play()
    		HumanoidRootPart.Anchored = true
    		AniamtionPlay:Play()
    		wait(5)
    		AniamtionPlay:Stop()
    		HumanoidRootPart.Anchored = false
    	end)
    end)
1 Like

So as i know to use tweeninfo.new you need contain more than time…

local ts = game:GetServuce("TweenService")

local info = TweenInfo.new(numberTime, Enum.EasingStyle.YourEasingStyle, Enum.EasingDirection, number of repeat count, bool reverse(false or true), time wait to start tweening)

local result = {
Your result, properties, that will tween too, example:
Transparency = 0.5;
}

local anim = ts:Create(tween object, info, result)
anim:Play()

I dont saw video, there was error, but to stop all animations, like your own do this:

yourAnimation:Stop()

To make your custom animation override roblox’s character’s animation make animation priority to action:

And do you have any errors in output?

Oh and always creating new animation, with load animation, makes it load much times, but you stop only last one created, make one local your animation on top, like there:

--// if its a local script, then use local player
local player = game.Players.LocalPlayer
local char = player.Character
local AniamtionPlay = char.Humanoid:LoadAnimation(Attackonwall)
local rp = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local Debris = game:GetService("Debris")
local attack = rp:WaitForChild("attack")
local Attackonwall = Instance.new("Animation")
Attackonwall.AnimationId = "rbxassetid://6253916213"

    attack.OnServerEvent:Connect(function(player)
    	local character = player.Character
    	local humanoidRP = character:WaitForChild("HumanoidRootPart")
    	local Humanoid = character:WaitForChild("Humanoid")
    	local RightHand = character:WaitForChild("RightHand")

    	local sword = Instance.new("Part")
    	sword.FormFactor = "Custom"
    	sword.Shape = Enum.PartType.Block
    	sword.Material = "Neon"
    	sword.Name = "RedRayForAttack"
    	sword.CFrame = humanoidRP.CFrame * CFrame.new(0,-1,-4)
    	sword.Anchored = true
    	sword.CanCollide = false	
    	sword.Parent = game.Workspace
    	
    	sword.Touched:Connect(function(hitted)
    		local HumanoidRootPart = hitted.Parent:FindFirstChild("HumanoidRootPart")
    		local HumanoidNPC = hitted.Parent:FindFirstChild("Humanoid")
    		local EHumanoidP = HumanoidRootPart.Position
    		local goal = {}
    		goal.CFrame = CFrame.new(game.Workspace.checkl.Position)
    		local tweenPlay = TweenService:Create(HumanoidRootPart, TweenInfo.new(0.1), goal):Play()
    		HumanoidRootPart.Anchored = true
    		AniamtionPlay:Play()
    		wait(5)
    		AniamtionPlay:Stop()
    		HumanoidRootPart.Anchored = false
    	end)
    end)