Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why won't the player do the animation?

Asked by 3 years ago

Basically, I have a tool that is supposed to make a player do an animation when you click on them. (I hold tool, and then click on a player. The player I click does an animation that I specified) But when I click, nothing happens.

First, there's this LocalScript in the tool.

local Player = game.Players.LocalPlayer
local Mouse  = Player:GetMouse()
local Tool   = script.Parent
local RemoteEvent = script.Parent:WaitForChild("RemoteEvent")

Tool.Activated:Connect(function()
    if Mouse.Target then
        RemoteEvent:FireServer(Mouse.Target)
    end
end)

Then, we have the regular script for when the RemoteEvent activates.

local RemoteEvent = script.Parent:WaitForChild("RemoteEvent")
local TargetTorso = nil
local Using       = false

RemoteEvent.OnServerEvent:Connect(function(player, part)
    if part:FindFirstChildOfClass'Humanoid' then
        local anim = Instance.new("Animation")
        anim.Parent = part
        anim.AnimationId = "rbxassetid://5336538893"
        anim:Play()
    end

end)

Answer this question