Error "FindFirstDescendant is not enabled"

When I try to use FindFirstDescendant for my movement script, I get an error telling me it isn’t enabled, any ideas how to fix this?

I’ve already tried using “FindFirstChild(“Weight”, true)” like the other posts on this issue have suggested, but that leaves me with another even weirder bug that glitches out my whole game.

Heres my whole script:

--Services--

local UIS = game:GetService("UserInputService")
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")

--References--

local localPlayer = Players.LocalPlayer
local character = localPlayer.Character or localPlayer.CharacterAdded:Wait()

--Skill Values--

local agility = character.SkillValues.Agility.Value

--EquippedWeight--

local helmetWeight = character:FindFirstDescendant("HelmetWeight")
local chestplateWeight = character:FindFirstDescendant("ChestplateWeight")
local greavesWeight = character:FindFirstDescendant("GreavesWeight")
local weaponWeight = character:FindFirstDescendant("WeaponWeight")

local helmetWeightValue = helmetWeight.Value
local chestplateWeightValue = chestplateWeight.Value
local greavesWeightValue = greavesWeight.Value
local weaponWeightValue = weaponWeight.Value

local combinedWeight = helmetWeightValue + chestplateWeightValue + greavesWeightValue + weaponWeightValue

--Movement Variables--

local baseSpeed = 16
local modifiedSpeed = baseSpeed * (agility * 0.15) / (combinedWeight)

local walkSpeed = modifiedSpeed * 1
local sprintSpeed = modifiedSpeed * 2
local crouchSpeed = modifiedSpeed * 0.5

local currentSpeed = character.Humanoid.MoveDirection.Magnitude

--Basic Movement--


--Walking--

local function setWalkSpeed()
	print("player spawned")
	character.Humanoid.WalkSpeed = walkSpeed
	print("Set walk speed")
end


--Sprinting (PC)--

local playerIsSprinting = false

local function beginSprint(input, gameProcessed)
	if not gameProcessed then
		if input.UserInputType == Enum.UserInputType.Keyboard then
			local keyCode = input.KeyCode
			
			if keyCode == Enum.KeyCode.LeftShift then
				if character.Humanoid.MoveDirection.Magnitude > 0 then
					print("player pressed shift")
					playerIsSprinting = true
					
					character.Humanoid.WalkSpeed = sprintSpeed
					print("player is sprinting")
				end
			end
		end
	end
end

local function endSprint(input, gameProcessed)
	if not gameProcessed then
		if input.UserInputType == Enum.UserInputType.Keyboard then
			local keyCode = input.KeyCode
			
			if keyCode == Enum.KeyCode.LeftShift then
				print("player stopped pressing shift")
				playerIsSprinting = false
				
				character.Humanoid.WalkSpeed = walkSpeed
				print("player is no longer sprinting")
			end
		end
	end
end

local function stopSprintWhenStoppedWalking()
	if playerIsSprinting == true and localPlayer.Character.Humanoid.MoveDirection.Magnitude <= 0 then
		print("player stopped pressing shift")
		playerIsSprinting = false
		
		localPlayer.Character.Humanoid.WalkSpeed = walkSpeed
		print("player is no longer sprinting")
	end
end

UIS.InputBegan:Connect(beginSprint)
UIS.InputEnded:Connect(endSprint)

RunService.RenderStepped:Connect(stopSprintWhenStoppedWalking)

Players.LocalPlayer.CharacterAdded:Connect(setWalkSpeed)
1 Like
1 Like

Already tried that, that glitched out my entire game for some reason, already mentioned it in the post

1 Like

Where did you use the recursive FindFirstChild? It should work as expected, maybe it just found some other item named “Weight”?

I was not reading thoroughly, my bad. When utilizing the recursive FFC, can you elaborate on the “weirder bug” you mentioned?

1 Like

FindFirstDescendant is the same as recursive FindFirstChild. Since this is a LocalScript, you should use WaitForChild.

1 Like

Kind of hard to explain, so here’s a video:

The glitch only occurs once I use the sprint function

There’s no indication that it could be the recursive FFC causing the bug. Now that your code is not showing up an error with the recursive FFC, something else in the sprint code is possibly causing lags. I don’t see any problems with your code, however.

Fixed it. Apparently the issue was that the equipment weight values had to be more than 0, for some reason. Turned out a recursive FindFirstChild wasn’t the problem.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.