#skill

1 messages · Page 1 of 1 (latest)

elder violet
#

I'm trying to make it so that when the player equips a tool called "Mugetsu" in Roblox, a LocalScript sends a RemoteEvent to the server, and then a Script inside ServerScriptService plays an animation.

Here is my current setup:

ReplicatedStorage

  • MugetsuEvent (RemoteEvent)

StarterPack

  • Mugetsu (Tool)

    • LocalScript
    • FloatAnim (Animation)

ServerScriptService

  • MugetsuServer (Script)

My LocalScript:

local tool = script.Parent
local remote = game.ReplicatedStorage:WaitForChild("MugetsuEvent")

tool.Equipped:Connect(function()
    remote:FireServer()
end)

My server script:

local remote = game.ReplicatedStorage:WaitForChild("MugetsuEvent")

remote.OnServerEvent:Connect(function(player)
    local char = player.Character
    if not char then return end

    local hum = char:FindFirstChildOfClass("Humanoid")
    if not hum then return end

    local animator = hum:FindFirstChildOfClass("Animator")
    if not animator then
        animator = Instance.new("Animator")
        animator.Parent = hum
    end

    local tool = char:FindFirstChild("Mugetsu")
    if not tool then return end

    local anim = tool:FindFirstChild("FloatAnim")
    if not anim or not anim:IsA("Animation") then return end

    local track = animator:LoadAnimation(anim)
    track:Play()
end)

The problem is that the animation does not play when I equip the tool.

Does anyone know what could be causing this or what I should check?

broken timber
elder violet
#

ok

elder violet