UNSOLVED DAY 17 ! Animation Track plays the animation but doesnt stop it

I have a question. Why are we stopping it again xd? Didnt it end ? Also Im trying it rn

Idk… if it didn’t stop the first time we stop it there (idk why it wouldn’t). Just make sure AnimationTrack.Looped is set to false.

1 Like

I understand I was a bit confused at first.

Wait. . . What the !?! It worked :sob: Thank you sooo much Idk how to thank you! I was waiting for this “17 DAYS” TYSM

1 Like

Ooof it seems like it still happens my current script (literally the same idk why it worked at that point it doesnt rn. Im only using the slot1 for this example but they are all working the same)

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local DropItem = ReplicatedStorage.RE.DropItem
local DropNonStackableItem = ReplicatedStorage.RE.DropNonStackableItem
local ViewModeltem = ReplicatedStorage.RE.ViewModeltem
local DeleteItem = ReplicatedStorage.RE.DeleteItem

local player = game.Players.LocalPlayer

local MainGui = script.Parent

local ActivatedGui = MainGui.Parent.Parent:WaitForChild("ViewModelSlotNumber")
local ActivatedGuiItem =  MainGui.Parent.Parent:WaitForChild("ViewModelCurrentItem")

local ViewModel = game.Workspace.Camera.ViewModel
local animations = {
	["Idle"] = ViewModel.AnimationController.Animator:LoadAnimation(ReplicatedStorage.ViewModelAnims.Idle),
	["HoldNormalItem"] = ViewModel.AnimationController.Animator:LoadAnimation(ReplicatedStorage.ViewModelAnims.HoldNormalItem),
	["Axe"] = ViewModel.AnimationController.Animator:LoadAnimation(ReplicatedStorage.ViewModelAnims.Axe),
	["Knife"] = ViewModel.AnimationController.Animator:LoadAnimation(ReplicatedStorage.ViewModelAnims.Knife),
	["Pickaxe"] = ViewModel.AnimationController.Animator:LoadAnimation(ReplicatedStorage.ViewModelAnims.Pickaxe)
}

animations.Idle.Looped = false
animations.HoldNormalItem.Looped = false
animations.Axe.Looped = false
animations.Knife.Looped = false
animations.Pickaxe.Looped = false

animations.Idle:Play()

-----------------------------SLOT-GET-VPFRAME------------------------------

local function getViewPortFrame(frame)
	for _, v in ipairs(frame:GetChildren()) do
		if v:IsA("ViewportFrame") then
			return v 
		end
	end
	return nil
end

local slotHandDelay = false --DELAYS

---------------------ATTACH-ITEM-------------------------------
function AttachItemToVM(ItemToHold)
	game.Workspace.Camera.ViewModel.ItemPos.Item.Part1 = ItemToHold
	ItemToHold.Position = game.Workspace.Camera.ViewModel.ItemPos.Position
	ItemToHold.Parent = game.Workspace.Camera.ViewModel.ItemPos
end


-----------------------------SLOT-1-------------------------------

MainGui.Slot1.MouseButton2Down:Connect(function()
	if ActivatedGui.Value ~= MainGui.Slot1.Name then
		if ActivatedGui.Value == MainGui.Slot1.Name then
			animations.Idle:Play()
		end
		local MainSlot = MainGui.Slot1
		local getItem = getViewPortFrame(MainSlot) 
		if MainGui.Slot1.HowMany.Value > 1 then
			local DropItem = DropItem:InvokeServer(getItem)
		else
			local DropNonStackableItem = DropNonStackableItem:InvokeServer(getItem)
		end	
	end
end)

MainGui.Slot1.MouseButton1Down:Connect(function()
	if slotHandDelay ~= true then
		local MainSlot = MainGui.Slot1
		local getItem = getViewPortFrame(MainSlot)
		local slot = "Slot1"

		if getItem then
			local ItemToHold = game.ReplicatedStorage.VMItemModels:FindFirstChild(getItem.Name):Clone()

			if ActivatedGui.Value == "" then
				if MainGui.SlotsItemName.Slot1.Value ~= "" then
					if MainGui.SlotsItemName.Slot1.Value == getItem.Name then
						if getItem:FindFirstChild(getItem.Name).WhatItem.Value == "Axe" then
                                                         --Useles rn
						elseif getItem:FindFirstChild(getItem.Name).WhatItem.Value == "Normal Item" then

							AttachItemToVM(ItemToHold)
							animations.Idle:Stop()
							animations.HoldNormalItem:Play()
							local guiItem = getItem.Name
							local ItemClass = "Normal Item"
							ViewModeltem:FireServer(slot, guiItem, ItemClass)
							animations.HoldNormalItem.Ended:Wait()

						elseif getItem:FindFirstChild(getItem.Name).WhatItem.Value == "Pickaxe" then
                                                    --Useles rn
						elseif getItem:FindFirstChild(getItem.Name).WhatItem.Value == "Knife" then

							AttachItemToVM(ItemToHold)
							animations.Idle:Stop()
							animations.Knife:Play()
							local guiItem = getItem.Name	
							local ItemClass = "Knife"
							ViewModeltem:FireServer(slot, guiItem, ItemClass)
							animations.Knife.Ended:Wait()  -- ENDİNG PART
							animations.Knife:Stop()
						end
					end
				end
			end
		end
	end
end)

-----------------------------SLOT-HAND-------------------------------

MainGui.SlotHand.MouseButton1Down:Connect(function()
	if slotHandDelay ~= true then
		slotHandDelay = true
		if ActivatedGuiItem.Value ~= ""  then
			game.Workspace.Camera.ViewModel.ItemPos:FindFirstChild(ActivatedGuiItem.Value):Destroy()
			local slot = ""
			local guiItem = ""
			local ItemClass = ""
			ViewModeltem:FireServer(slot, guiItem, ItemClass)

			animations.Idle:Stop()
			animations.Idle:Play()
			animations.HoldNormalItem:Stop()
			animations.Axe:Stop()
			animations.Knife:Stop()
			animations.Pickaxe:Stop()
			wait(1)
			slotHandDelay = false
		end
	end
end)

ViewModeltem.OnClientEvent:Connect(function()
	animations.Idle:Stop()
	animations.Idle:Play()
	animations.HoldNormalItem:Stop()
	animations.Axe:Stop()
	animations.Knife:Stop()
	animations.Pickaxe:Stop()
end)

player.PlayerGui.ViewModelCurrentItem.Changed:Connect(function()
	if player.PlayerGui.ViewModelCurrentItem.Value == "" or player.PlayerGui.ViewModelCurrentItem.Value == nil then
		animations.Idle:Stop()
		animations.Idle:Play()
		animations.HoldNormalItem:Stop()
		animations.Axe:Stop()
		animations.Knife:Stop()
		animations.Pickaxe:Stop()
	else
		animations.Idle:Stop()
	end
end)

DeleteItem.OnClientEvent:Connect(function()
	local slot = ""
	local guiItem = ""	
	local ItemClass = ""
	if game.Workspace.Camera.ViewModel.ItemPos:FindFirstChild(ActivatedGuiItem.Value) then game.Workspace.Camera.ViewModel.ItemPos:FindFirstChild(ActivatedGuiItem.Value):Destroy()
	else
		print("Game Broken or Deleted from another script")
	end	
	wait(tick)
	ViewModeltem:FireServer(slot, guiItem, ItemClass)
	animations.Idle:Stop()
	animations.Idle:Play()
	animations.HoldNormalItem:Stop()
	animations.Axe:Stop()
	animations.Knife:Stop()
	animations.Pickaxe:Stop()
end)

script.Parent.TextButton.MouseButton1Click:Connect(function()
	print(ViewModel.AnimationController:GetPlayingAnimationTracks()) --print playing animations
end)