But I would like the animation to work when I request an event
But I would like the animation to work when I request an event…This doesn’t work when you request an event
I would like to have the animation work when you request an event
okay, now this works, you just have to use this:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local eventClean = ReplicatedStorage:WaitForChild("eventclean")
eventClean.OnClientEvent:Connect(function(player, spill)
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)
now show me what current script you are calling form
No logs appear and no animations work.
yes I know, can you tell me which scrip calls the event?
I think something is wrong with the place where you request an event and receive an event request.
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 function SetupSpill(spill)
local prompt = spill:WaitForChild("ProximityPrompt")
local lock = false
prompt.Triggered:Connect(function()
if lock then return end
local character = player.Character or player.CharacterAdded:Wait()
local tool = character:FindFirstChildOfClass("Tool")
if not tool or tool.Name ~= "Mop" then
return
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
lock = true
-- Spill을 청소하는 요청을 서버로 보냄
eventClean: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)
This localscript and This
StarterPlayer.StarterPlayerScripts.ThisScript
For debugging, use this script:
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 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')
eventClean: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)
Now, trigger the prompt, and tell me what logs you get
prompt got Triggered! - 클라이언트 - ThisScript:20
22:03:02.267 lock is false, continue - 클라이언트 - ThisScript:22
22:03:02.267 continue - 클라이언트 - ThisScript:29
22:03:02.267 continue - 클라이언트 - ThisScript:36
22:03:02.267 fire - 클라이언트 - ThisScript:39
22:03:02.267 요청 보냄 - 클라이언트 - ThisScript:41
But not working…
Why???
okay, so the script fires, that’s good, now it is not detected… let me see… nothing else happens after this?:
2:03:02.267 fire - 클라이언트 - ThisScript:39
22:03:02.267 요청 보냄 - 클라이언트 - ThisScript:41
Yes
After that there are no other logs and the animations don’t work either.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local eventClean = ReplicatedStorage:WaitForChild("eventclean")
eventClean.OnClientEvent:Connect(function(player, spill)
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)
The log here didn’t show anything
try and use this:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local eventClean = ReplicatedStorage:WaitForChild("eventclean")
warn('loaded "EventClean_event" =', eventClean)
eventClean.OnClientEvent:Connect(function(player, spill)
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)
loaded “EventClean_event” = eventclean - 클라이언트 - LocalScript:5
22:12:31.581 console - 클라이언트 - PlayerDeviceDetect:25
22:12:33.386 Request failed | HttpError: InvalidUrl - 서버 - Script:144
22:12:41.483 Request failed | HttpError: InvalidUrl - 서버 - Script:144
22:12:41.744 2 - 서버 - Spills:60
22:12:42.479 prompt got Triggered! - 클라이언트 - ThisScript:20
22:12:42.479 lock is false, continue - 클라이언트 - ThisScript:22
22:12:42.479 continue - 클라이언트 - ThisScript:29
22:12:42.479 continue - 클라이언트 - ThisScript:36
22:12:42.480 fire - 클라이언트 - ThisScript:39
22:12:42.480 요청 보냄 - 클라이언트 - ThisScript:41
It seems to load fine, but why doesn’t it work?
I think this will solve it, use this script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local eventClean = ReplicatedStorage:WaitForChild("eventclean")
warn('loaded "EventClean_event" =', eventClean)
eventClean.OnServerEvent:Connect(function(player, spill)
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)