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)
--------------------------------------------------------------------------------------------------
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"