How can i add to this script so that when im playing an animation (attack animation with sword) it anchors the humanoid? I don’t want players to be able to run and swing the sword at the same time.
wait(3)
Player = game.Players.LocalPlayer.Character
Animation1 = Player.Humanoid:LoadAnimation(script.Slices)
Animation2 = Player.Humanoid:LoadAnimation(script.Spin)
Animation3 = Player.Humanoid:LoadAnimation(script.BackFlipStab)
Animation4 = Player.Humanoid:LoadAnimation(script.DownSlice)
CanFly = true
script.Parent.Parent.Activated:connect(function()
local Fly = math.random(1,5)
if Fly == 1 and CanFly == true then
Animation1:Play()
CanFly = false
wait(0.5)
CanFly = true
else if Fly == 2 and CanFly == true then
Animation2:Play()
CanFly = false
wait(0.5)
CanFly = true
else if Fly == 3 and CanFly == true then
Animation3:Play()
CanFly = false
wait(0.5)
CanFly = true
else if Fly == 4 and CanFly == true then
Animation4:Play()
CanFly = false
wait(0.5)
CanFly = true
end
end
end
end
end)
task.wait(3)
local Player = game.Players.LocalPlayer or game.Players.PlayerAdded:Wait()
local Character = Player.Character or Player.CharacterAdded:Wait()
local Animation1 = Player.Humanoid:LoadAnimation(script.Slices)
local Animation2 = Player.Humanoid:LoadAnimation(script.Spin)
local Animation3 = Player.Humanoid:LoadAnimation(script.BackFlipStab)
local Animation4 = Player.Humanoid:LoadAnimation(script.DownSlice)
local CanFly = true
script.Parent.Parent.Activated:connect(function()
local Fly = math.random(1,5)
if Fly == 1 and CanFly == true then
Animation1:Play()
CanFly = false
Character.HumanoidRootPart = true
task.wait(0.5)
CanFly = true
Character.HumanoidRootPart = false
else if Fly == 2 and CanFly == true then
Animation2:Play()
Character.HumanoidRootPart = true
CanFly = false
task.wait(0.5)
CanFly = true
Character.HumanoidRootPart = false
else if Fly == 3 and CanFly == true then
Animation3:Play()
CanFly = false
Character.HumanoidRootPart = true
task.wait(0.5)
CanFly = true
Character.HumanoidRootPart = false
else if Fly == 4 and CanFly == true then
Animation4:Play()
CanFly = false
Character.HumanoidRootPart = true
task.wait(0.5)
CanFly = true
Character.HumanoidRootPart = false
end
end
end
end
end)
If you want to anchor the player just use:
Character.HumanoidRootPart.Anchored = false OR true
It better to do so. If you Anchor all the other Child in teh player(Head,Torso,ETC),it would be mess if you want to unanchor it back since HumanoidRootPart need to be always Unachored.
-- idk what that wait is but use task.Wait if your going to use wait
local player = game:GetService("Players").LocalPlayer
local Character = Player.Character
local Humanoid = Character.Humanoid
local animations = {
Animation1 = Player.Humanoid:LoadAnimation(script.Slices),
Animation2 = Player.Humanoid:LoadAnimation(script.Spin),
Animation3 = Player.Humanoid:LoadAnimation(script.BackFlipStab),
Animation4 = Player.Humanoid:LoadAnimation(script.DownSlice)
}
local canFly = true
local function giveAnimation()
local Fly = math.Random(1,5)
if canFly then
local animation = animations[fly]
canFly = false
animation:Play()
humanoid.Walkspeed = 0
humanoid.JumpPower= 0
task.Wait(0.5)
humanoid.Walkspeed = 16 -- or whatever the orginal values are
humanoid.JumpPower= 50
canFly = true
end
end
script.Parent.Parent.Activated:connect(giveAnimation)