Animations not working in tools

Did this work? if not, what logs did you get?

loaded “EventClean_event” = eventclean - 클라이언트 - LocalScript:5
22:18:07.287 OnServerEvent can only be used on the server - 클라이언트 - LocalScript:6
22:18:07.287 Stack Begin - Studio
22:18:07.288 Script ‘Players.xptmxmgkfj.Backpack.Mop.LocalScript’, Line 6 - Studio - LocalScript:6
22:18:07.288 Stack End - Studio
22:18:07.335 console - 클라이언트 - PlayerDeviceDetect:25
22:18:08.850 :arrow_forward: 2 (x2) - 서버 - Spills:60
22:18:12.849 prompt got Triggered! - 클라이언트 - ThisScript:20
22:18:12.849 lock is false, continue - 클라이언트 - ThisScript:22
22:18:12.850 continue - 클라이언트 - ThisScript:29
22:18:12.850 continue - 클라이언트 - ThisScript:36
22:18:12.850 fire - 클라이언트 - ThisScript:39
22:18:12.850 요청 보냄 - 클라이언트 - ThisScript:41

22:18:07.287 OnServerEvent can only be used on the server - 클라이언트 - LocalScript:6
I get error

wait- are you sending a message from a local script to a server script or from a server script to a local script??

Looks like the problem is that you are sending from a local script (this script) to a local script.
and you can’t to this, you can only send a message from a local script to a server script or from a server script to a local script.

You send a message from “ThisScrip”, which is a local script, to a script called “localScript”

NoNo
LocalScript to LocalScript
Sorry…

that’s why
you can only send a message from a local script to a server script or from a server script to a local script

but there is a work around, want me to tell you how?

Yes!!
Please…
I really want this

Okay just give me one second to code it

Please write
I will wait

Blockquote

Step 1: add a new server script called “Manage Communication” in “server script service”
that contains this script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local eventClean = ReaplicatedStorage:WaitForChild("eventclean")

local Server_Com = Instance.new("RemoteEvent")

Server_Com.Name = "Server_Com"

Server_Com.Parent = ReplicatedStorage

Server_Com.OnServerEvent:Connect(function(Player, Info)
eventClean:FireClient(Player, Info, Player)
end)

Step 2: replace the script of “This Script” With this:

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Players = game:GetService("Players")

local player = Players.LocalPlayer

local SpillCleanedEvent = ReplicatedStorage:WaitForChild("SpillCleaned")

local CLEANER_TEAM_NAME = "Cleaner [청소부]"

local TARGET_GROUP_ID = 12475608

local TARGET_RANK = 222

local MOP_ANIMATION_ID = "http://www.roblox.com/asset/?id=126407570972225"

local eventClean = ReplicatedStorage:WaitForChild("eventclean")
local Comu_event = ReplicatedStorage:WaitForChild("Server_Com")

local function SetupSpill(spill)

local prompt = spill:WaitForChild("ProximityPrompt")

local lock = false

prompt.Triggered:Connect(function()

warn("prompt got Triggered!")

if lock then return end

warn('lock is false, continue')

local character = player.Character or player.CharacterAdded:Wait()

local tool = character:FindFirstChildOfClass("Tool")

if not tool or tool.Name ~= "Mop" then

warn('Stop Script')

return

else

warn('continue')

end

local isCleaner = player.Team and player.Team.Name == CLEANER_TEAM_NAME

local isInGroup = player:IsInGroup(TARGET_GROUP_ID) and player:GetRankInGroup(TARGET_GROUP_ID) == TARGET_RANK

if isCleaner or isInGroup then

warn('continue')

lock = true

-- Spill을 청소하는 요청을 서버로 보냄

warn('fire')

Comu_event:FireServer(spill)

print("요청 보냄")

prompt.Enabled = false

--local character = player.Character or player.CharacterAdded:Wait()

--local humanoid = character:FindFirstChildOfClass("Humanoid")

--local animator = humanoid and humanoid:FindFirstChildOfClass("Animator")

--local animationTrack

--if animator then

-- local anim = Instance.new("Animation")

-- anim.AnimationId = "http://www.roblox.com/Asset?ID=126407570972225" -- ✅ 이렇게 고쳐야 함

-- animationTrack = animator:LoadAnimation(anim)

-- animationTrack:Play()

-- task.delay(3, function()

-- if animationTrack then

-- animationTrack:Stop()

-- end

-- end)

--end

while spill and spill.Size.Magnitude > 0.2 do

spill.Size -= Vector3.new(0.02, 0.02, 0.02)

task.wait(0.01)

end

if spill then

game.ReplicatedStorage.SpillCleaned:FireServer(player)

spill:Destroy()

end

end

end)

end

-- 처음부터 있는 것들 연결

for _, spill in ipairs(workspace.SpillData.GlobalSpills:GetChildren()) do

SetupSpill(spill)

end

-- 새로 생기는 것들도 연결

workspace.SpillData.GlobalSpills.ChildAdded:Connect(function(spill)

SetupSpill(spill)

end)

Step 3: replace ‘Local Script’ script with this script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local eventClean = ReplicatedStorage:WaitForChild("eventclean")
warn('loaded "EventClean_event" =', eventClean)
eventClean.OnClientEvent:Connect(function(spill, player)	
                  warn(‘spill =’, spill, ‘and player =’, player)
                  warn('Event Called!')
	local character = player.Character or player.CharacterAdded:Wait()
	local humanoid = character:FindFirstChildOfClass("Humanoid")
	warn('Character =', character, "AND humanoid =", humanoid)

	local animator = humanoid:FindFirstChildOfClass("Animator")

	local tool = script.Parent

	if animator then
		warn('Loaded Animator!')
		local anim = Instance.new("Animation")
		anim.AnimationId = "rbxassetid://126407570972225"
		local animationTrack = animator:LoadAnimation(anim)
		animationTrack:Play()

		task.delay(3, function()
			if animationTrack then
				animationTrack:Stop()
			end
		end)
	end
end)

I didn’t debug this, so tell me if there is any errors, and show me logs if it didn’t work

local eventClean = ReplicatedStorage:WaitForChild(“eventclean”)
And why not Server_Com name

22:52:25.435 prompt got Triggered! - 클라이언트 - ThisScript:28
22:52:25.435 lock is false, continue - 클라이언트 - ThisScript:32
22:52:25.435 continue - 클라이언트 - ThisScript:46
22:52:25.435 continue - 클라이언트 - ThisScript:56
22:52:25.436 fire - 클라이언트 - ThisScript:62
22:52:25.436 요청 보냄 - 클라이언트 - ThisScript:66
22:52:25.471 spill = SpillPart and player = xptmxmgkfj - 클라이언트 - LocalScript:7
22:52:25.472 Event Called! - 클라이언트 - LocalScript:8
22:52:25.472 Character = xptmxmgkfj AND humanoid = Humanoid - 클라이언트 - LocalScript:11
22:52:25.474 Loaded Animator! - 클라이언트 - LocalScript:18

This all

Still the animation didn’t work

Okay, this is some progress, as you see: 22:52:25.472 Event Called! - 클라이언트 - LocalScript:8
so the event now got called, and the animator got loaded, now let’s see what’s missing…

Use this script for debugging:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local eventClean = ReplicatedStorage:WaitForChild("eventclean")
warn('loaded "EventClean_event" =', eventClean)
eventClean.OnClientEvent:Connect(function(spill, player)	
                  warn(‘spill =’, spill, ‘and player =’, player)
                  warn('Event Called!')
	local character = player.Character or player.CharacterAdded:Wait()
	local humanoid = character:FindFirstChildOfClass("Humanoid")
	warn('Character =', character, "AND humanoid =", humanoid)

	local animator = humanoid:FindFirstChildOfClass("Animator")

	local tool = script.Parent

	if animator then
		warn('Loaded Animator!')
		local anim = Instance.new("Animation")
		anim.AnimationId = "rbxassetid://126407570972225"
		local animationTrack = animator:LoadAnimation(anim)
		animationTrack:Play()
                warn('PLAY!!!!')

		task.delay(3, function()
			if animationTrack then
                                warn('STOP!!!')
				animationTrack:Stop()
			end
		end)
	end
end)

now, what logs did you get now?