Help play animation after called a FireClient()

So, I’ve been trying to make some sort of animation play for all the players found inside a Region3 but it doesn’t seem to work with any of the work I’ve done. Does anyone have an idea on how to fix it?

ServerSide
local region = game.Workspace.MutationRegion3

local region3 = Region3.new(region.Position-(region.Size/2), region.Position+(region.Size/2))

local event = game.ReplicatedStorage.AnimatePlayer

game.Workspace.Trigger.ProximityPrompt.Triggered:Connect(function()
    local partsInRegion = workspace:FindPartsInRegion3(region3, region, 1000)
    local playersFound = {}
    for i, prt in pairs(partsInRegion) do
        if prt.Parent:FindFirstChild("Humanoid") then
            print("Player ",prt.Parent.Name," Found")
            event:FireClient()
        end
    end
end)
ClientSide
local plr = game.Players.LocalPlayer
local char = plr.Character

game.ReplicatedStorage.AnimatePlayer.OnClientEvent:Connect(function()
	local animation = Instance.new("Animation")
	local hum = char:FindFirstChild("Humanoid")
	animation.Parent = char
	animation.AnimationId = "rbxassetid://[INSERTIDHERELOL]"
	local loadedTrack = hum:LoadAnimation(animation)
	loadedTrack:Play()
end)
1 Like

You need the Animation INSIDE of the LocalScript.

Script:

-- It's an example, you guys, sorry -------------------------
local player = game.Players.LocalPlayer

script.Parent.Activated:Connect(function()
	if player.Debounce.Value == false then
		game.ReplicatedStorage.RemoteEvents.Power:FireServer(script.Parent.Values)
		
		local action = script.Parent.Parent.Humanoid:LoadAnimation(script.Animation)
		
		action:Play()
	end
end)

It’s because you aren’t specifying which player to fire the event to, try this instead for your server side code:

--//Services
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

--//Variables
local event = ReplicatedStorage.AnimatePlayer
local region = workspace.MutationRegion3
local region3 = Region3.new(region.Position-(region.Size/2), region.Position+(region.Size/2))

--//Functions
workspace.Trigger.ProximityPrompt.Triggered:Connect(function()
	local partsInRegion = workspace:FindPartsInRegion3(region3, region, 1000)
	local playersFound = {}
	
	for i, part in ipairs(partsInRegion) do
		local player = Players:GetPlayerFromCharacter(part.Parent)
		
		if player then
			print("Player", player.Name, "Found")
			event:FireClient(player)
		end
	end
end)
1 Like

He’s trying to get every player from the parts found in partsInRegion so it is actually needed, not just the player who triggered the proximity prompt.

1 Like

But Triggered:Connect(function(player) only returns the player that triggered the proximity prompt.

Basically what I meant is exactly this

1 Like

There’s only one issue, how would I activate the local script for the exact player returned in the FireClient() event?

It already activates the local script for the player when the remote event is fired to their client.

Thank you very much! It works as intended.