#animation

1 messages · Page 1 of 1 (latest)

quaint dew
#
local player = game.Players.LocalPlayer
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:WaitForChild("PlayToolAnimation")
local sound = tool:FindFirstChild("Sword Swing Metal Heavy")

local character
local humanoid
local moveConnection



local canAttack = true
local cooldownTime = 0.8


tool.Equipped:Connect(function()
    character = player.Character or player.CharacterAdded:Wait()
    humanoid = character:WaitForChild("Humanoid")

    RemoteEvent:FireServer("Idle", tool)

    moveConnection = humanoid.Running:Connect(function(speed)
        if speed > 0 then
            RemoteEvent:FireServer("Moving", tool)
        else
            RemoteEvent:FireServer("Idle", tool)
        end
    end)
end)

tool.Unequipped:Connect(function()
    if moveConnection then
        moveConnection:Disconnect()
        moveConnection = nil
    end

    RemoteEvent:FireServer("Stop", tool)
end)




tool.Activated:Connect(function()
    if not canAttack then return end

    canAttack = false
    RemoteEvent:FireServer("Swing", tool)
    sound:Play()

    task.delay(cooldownTime, function()
        canAttack = true
    end)
end)

here is the problem:

you equip tool, idle plays, you start walking, moving anim plays, u stop walking, moving anim keeps playing and idle doesnt play

novel vaultBOT
#

studio** You are now Level 3! **studio

void jetty
#

if speed > 0 this might be the problem

#

so try setting it to 0.5

#

cuz sometimes but player moving speed can be at like 0.01 u/s

#
local tool = script.Parent
local player = game.Players.LocalPlayer
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:WaitForChild("PlayToolAnimation")
local sound = tool:FindFirstChild("Sword Swing Metal Heavy")

local character
local humanoid
local moveConnection

local canAttack = true
local cooldownTime = 0.8

local lastState = nil
local function setState(state)
    if state == lastState then return end
    lastState = state
    RemoteEvent:FireServer(state, tool)
end

tool.Equipped:Connect(function()
    character = player.Character or player.CharacterAdded:Wait()
    humanoid = character:WaitForChild("Humanoid")

    setState("Idle")

    moveConnection = humanoid.Running:Connect(function(speed)
        if speed > 0.5 then
            setState("Moving")
        else
            setState("Idle")
        end
    end)
end)

tool.Unequipped:Connect(function()
    if moveConnection then
        moveConnection:Disconnect()
        moveConnection = nil
    end
    lastState = nil
    RemoteEvent:FireServer("Stop", tool)
end)

tool.Activated:Connect(function()
    if not canAttack then return end
    canAttack = false

    RemoteEvent:FireServer("Swing", tool)
    if sound then sound:Play() end

    task.delay(cooldownTime, function()
        canAttack = true
    end)
end)
quaint dew
#

okay

#

big thanks i will try.

#

nwa it still doesn't stop the moving animation 😔

void jetty
#

maybe your moving animation is on loop ?

#

try adding this somewhere where you play the animations:

local humanoid = npc:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")

local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://ID"

local track = animator:LoadAnimation(animation)

track.Looped = false --<---- here

track:Play()
quaint dew
#

shi man thanks imma try it

#

my fault i went for a big nap