How it looks like in-game:
robloxapp-20241209-1807162.wmv (715.9 KB)
In Animation Editor:
robloxapp-20241209-1808346.wmv (380.0 KB)
Code:
local isProcessing = false
function hi(player)
if isProcessing then
return
end
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:FindFirstChild("Humanoid")
local backpack = player:FindFirstChild("Backpack")
local itemTemplate = game.ServerStorage:FindFirstChild("наши дети")
local animation = script:FindFirstChild("CollectSnow")
for _, item in pairs(backpack:GetChildren()) do
if item.Name == itemTemplate.Name then
return
end
end
isProcessing = true
local animTrack = humanoid:LoadAnimation(animation)
animTrack:Play()
task.wait(3)
animTrack:Stop()
local newItem = itemTemplate:Clone()
newItem.Parent = backpack
isProcessing = false
end
script.Parent.ClickDetector.MouseClick:Connect(hi)