Problems with my flashlight system (Not Tool)

The problem is it gives me a message says “Attempt to index nil with Destroy 38”
here is my code

local Flashlight = game.ReplicatedStorage:FindFirstChild("FlashLightSystem"):FindFirstChild("Flashlight"):Clone()
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.Character.ChildAdded:Wait()
local UserInput = game:GetService("UserInputService")
local EquipService = Flashlight:FindFirstChild("Equipped/Unequipped").Value
local Part1 = Flashlight:FindFirstChild("Grip")
local Caneaquip = Flashlight:FindFirstChild("CanEquip/Unequip").Value
local Weld = Instance.new("Motor6D",Part1)
local Animations = Flashlight:FindFirstChild("Animations")
------------------------------------------------
--Functions
UserInput.InputBegan:Connect(function(Keycode)
	local LoadEquip = Character:FindFirstChild("Humanoid"):LoadAnimation(Animations.Equipped)
	--Equip
	local Character = Player.Character
	local NewFlashLight = script.Parent:FindFirstChild("FlashLight")
	if Keycode.KeyCode == Enum.KeyCode.F and Caneaquip == true and EquipService == false then
		Flashlight.Parent = Player.Character
		Weld.Part0 = Character:FindFirstChild("Right Arm")
		Weld.Part1 = Part1
		Caneaquip = false
		
		LoadEquip:Play()
		wait(4)
		Caneaquip = true
		EquipService = true
		--Unequip
	else
		
		if UserInput.InputBegan and Keycode.KeyCode == Enum.KeyCode.F and Caneaquip == true and EquipService == true then

			Caneaquip = false
			local LoadEquip2 = Character:FindFirstChild("Humanoid"):LoadAnimation(Animations.Unequipped)
			LoadEquip:Stop()
			LoadEquip2:Play()
			wait(0.3)
			NewFlashLight:Destroy()
			wait(4)
			Caneaquip = true
			EquipService = false
			
		end
	end
end)

--------------------------------------------------------------------------------------------------

Also the Animation 1 doesn’t stop playing

1 Like

Also it cant stop and play new animation for some reason?

1 Like

Hey, can you print the values before destroying the flashlight? The error says that it doesnt exists

1 Like

Whenever an error occurs, your script stops, so focus on fixing the error first

1 Like

I cloned the flashlight then added it to the player character i now want to destroy it from the character itself

1 Like

I know but we need the prints so we can know exactly what it finds, put print(NewFlashLight) before destroying it

2 Likes

Alright let me see what will it print then i will reply to you.

2 Likes

well it printed for me nil sadly

1 Like

As i suspected, where is the flashlight located at and parented to? If its in on the character you should do player.Character.FlashLight:Destroy()

2 Likes

Nice it worked but now it destroys the flashlight .but the player doesnt stop the animation so its very terrible right now

1 Like

Isnt it supposed to destroy the flashlight?

2 Likes

it destroyed it very well but the player doesnt stop the flashlight equip animation

2 Likes

Also what do you mean not stopped? Is it on loop? (It was sent right before you sent it)

2 Likes

Actually its not in loop it is Just an animation were the player turns it on then starts the idle animation which stop at the keyframe no. 100008 ;-;

1 Like

Imo you can make your own animation that holds the flashlight (1 keyframe on loop) but anyways, im still confused, can you send a video?

1 Like

robloxapp-20230920-2308469.wmv (802.3 KB)
here is the video

I cant really help past that sorry

1 Like

It says " Equipped is not a valid member of Folder “Animations” " i think i am having problems with the child call

No problem i fixed this issue the new ones is when you use the flahslight 1 time then turn it off then use it again it says ''The Parent property of Flashlight is locked, current parent: NULL, new parent wolfmanOs"

What is acctually this issue? i did never see ones like that