Local script animation | FireClient(Player1)

Why it doesn’t work?

image

-- local script
local ArrestedAnimation = script:WaitForChild("Animation")
local bool = true


    game.ReplicatedStorage.IArresed.OnClientEvent:Connect(function()
    	if bool == true then
    		bool = false
    		ArrestedAnimation:Play()
    		wait(5)
    		bool = true		
    	end
    end)

image

-- part of the script

function onTouched(hit) 
	local Player1 = game.Players:FindFirstChild(Part.Parent.Parent.Name)
	game.ReplicatedStorage.ArrestPrisoner:FireClient(Player1)

I have to make this as a list since I believe you have several problems.

  • Use humanoid:LoadAnimation(animOBJ)
    (or animator:LoadAnimation(animOBJ) (code from the third post by @1000knives))

  • The part on the ontouched function is not the player’s body parts and is supposed to be hit, and adding another parent just causes it to get the parent of the player unless it’s an accessory. (Fixed by removing the parent and replacing Part with hit.)

function onTouched(hit) 
	local Player1 = game.Players:FindFirstChild(hit.Parent.Name)
    if Player1 then -- detect if it exists otherwise it would make errors.
       game.ReplicatedStorage.ArrestPrisoner:FireClient(Player1)
    end
  • Maybe because ArrestPrisoner is supposed to be IArresed (vice versa)?

Pretty sure its due to the fact you aren’t loading the animation via :LoadAnimation(). Try adding:

local animator = char.Humanoid:FindFirstChildOfClass(“Animator”)
local animtrack = animator:LoadAnimation(ArrestedAnimation)
animtrack:Play()