Check if item exists in object

Im trying to add leg weights to my game, but I keep getting an error “LegWeights is not a valid member of Part “Workspace.KidsInTheWoodsYTube.Right Leg” - Client - Main:24”
please help

thanks in advance

-Script

local t = script.Parent
local PS = game:GetService("PhysicsService")
local path = game:GetService("PathfindingService")
local rp = game:GetService("ReplicatedStorage")

script.Parent.On.OnServerEvent:Connect(function(character)
	local legWeightL = rp.LegWeights:Clone()
	legWeightL.Parent = character.Character:WaitForChild("Left Leg")
	legWeightL.Weld.Part1 = character.Character:WaitForChild("Left Leg")
	
	local legWeightR = rp.LegWeights:Clone()
	legWeightR.Parent = character.Character:WaitForChild("Right Leg")
	legWeightR.Weld.Part1 = character.Character:WaitForChild("Right Leg")
end)

script.Parent.Off.OnServerEvent:Connect(function(character)
	character.Character:WaitForChild("Left Leg"):WaitForChild("LegWeights"):Destroy()

	character.Character:WaitForChild("Right Leg"):WaitForChild("LegWeights"):Destroy()
end)

-Local script

function Action(input, typing)
	if typing or hum:GetState() == dead or t:GetAttribute("CloneIsAlive") == true or t:GetAttribute("CA") == false then return end
	
	t:SetAttribute("CA", false)
	
	Controls:Disable()
	
	local animation = Instance.new("Animation")
	animation.AnimationId = "rbxassetid://9765012944"
	animation.Parent = c:WaitForChild("Humanoid")
	
	script.Parent["Naruto Jutsu Sound Effect"]:Play()
	script.Parent.RasenganSFX:Play()

	loadedAnimation = c:WaitForChild("Humanoid"):LoadAnimation(animation)
	loadedAnimation:Play()
	
	--9765462142
	
	wait(0.5);
	
	local i = 0
	
	repeat
		re:FireServer()
		i = i + 1
	until i == 1;
	
	local animation = Instance.new("Animation")
	animation.AnimationId = "rbxassetid://9765462142"
	animation.Parent = c:WaitForChild("Humanoid")
	
	loadedAnimation = c:WaitForChild("Humanoid"):LoadAnimation(animation)
	loadedAnimation:Play()
	
	wait(0.5)
	
	script.Parent.SpawnRas:FireServer(plr)
	
	wait(2.5)
	
	loadedAnimation:Stop()
	
	local animation = Instance.new("Animation")
	animation.AnimationId = "rbxassetid://9771498915"
	animation.Parent = c:WaitForChild("Humanoid")
	
	loadedAnimation = c:WaitForChild("Humanoid"):LoadAnimation(animation)
	loadedAnimation:Play()
	
	Controls:Enable()
	
	local a = true
	
	repeat
		if plr.Character["Right Arm"]:FindFirstChild("Rasengan") ~= nil then
			a = true
			wait()			
		else
			a = false
		end
	until a == false
	
	
	
	loadedAnimation:Stop()
	script.Parent.RasenganSFX:Stop()
		
	wait(t:GetAttribute("Cooldown"))
	t:SetAttribute("CA", true)
end

In which event is the error occurring, the on or off event?

Why not just change character there to player so there’s no confusion

the error is occurring when it checks if the leg weights are on or off

Well thats not 100% true because you never check if they are on.

Change that whole function (and event) to:

script.Parent.Off.OnServerEvent:Connect(function(player)
    local character = player.Character or player.CharacterAdded:Wait()
    if not character:FindFirstChild("Left Leg"):FindFirstChild("LegWeights") and not character:FindFirstChild("Right Leg"):FindFirstChild("LegWeights") then return print("Hey, no leg weights exists") end
    character:FindFirstChild("Left Leg"):FindFirstChild("LegWeights"):Destroy()
	character:FindFirstChild("Right Leg"):FindFirstChild("LegWeights"):Destroy()
end)