Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How would I loop though all players and apply a animation to them?

I try to do it but it only apply it to one person heres my code:

local T = false
local S = script:WaitForChild("Sound")
local A = script.Parent.Humanoid:LoadAnimation(game.Players.LocalPlayer.PlayerGui.AnimationsNew.Frame.TextButton.Animation)

game.Players.LocalPlayer.PlayerGui.AnimationsNew.Frame.TextButton.MouseButton1Click:Connect(function()
	local Humanoid = game.Players.LocalPlayer.Character.Humanoid
		local ActiveTracks = Humanoid:GetPlayingAnimationTracks()
		for _,v in pairs(ActiveTracks) do
		    v:Stop()
		end
	if(T == false)then
		A:Play()
		S:FireServer()
		T = true
		elseif(T == true)then
		A:Stop()
		S:FireServer()
		T = false
	end
		
end)

1 answer

✓ Accepted answer

This is a way to loop all players using loops

for i,v in pairs(game.Players:GetChildren()) do -- Get all player to a table, v is aplayer
	v.Character -- This is the character
end

This discussion is preserved as it was. New answers, comments, and votes are closed.