Need help - Attempt to index nil with 'CFrame'

What is the issue?
Getting "Attempt to index nil with CFrame" error, tried lots of possible solutions and I’m not able to fix this… So if someone could help me I would appreciate it!

What solutions have you tried so far?
Didn’t found any solution related to this issue…

Marked each line as --[ LINE X ]]

[image]

BlockIndicator
return function (Victim : Model, Damage : NumberValue, Color : Color3, Size : UDim2, font : Enum.Font)

	if Victim then
		Color = Color or Color3.new(1)
		Size = Size or Sizes.Small
		Damage = tostring(Damage)
		font = font or script.Damage.Bill.T1.Font
		
		local DamageIndicator = script:WaitForChild("Damage"):Clone()
		DamageIndicator.Bill.Size = Size
		--[[ LINE 23 ]] DamageIndicator.Parent, DamageIndicator.CFrame, DamageIndicator.Anchored = workspace, Victim:FindFirstChild("HumanoidRootPart").CFrame * CFrame.new(math.random(unpack(RandomOffset)), 0, 0), false
		DamageIndicator.Bill.T1.Text = "-"..Damage; DamageIndicator.Bill.T1:FindFirstChild("Text").Text = Damage 
		
		DamageIndicator.Bill.T1.Font = font
		DamageIndicator.Bill.T1:WaitForChild("Text").Font = font
		
		local Tween = TweenService:Create(DamageIndicator.Bill.T1:FindFirstChild("Text"), TweenInfo.new(.5, FadeOutInfo.EasingStyle, FadeOutInfo.EasingDirection), {TextColor3 = Color})
		Tween:Play();
		Tween:Destroy();
		
		task.delay(IndicatorLength, function()
			local Tween = TweenService:Create(DamageIndicator.Bill.T1:FindFirstChild("Text"), TweenInfo.new(1, FadeInInfo.EasingStyle, FadeInInfo.EasingDirection), {TextColor3 = Color3.fromRGB(255,255,255)})
			Tween:Play();
			Tween:Destroy();
			task.delay(1, function()
				DamageIndicator:Destroy()
			end)
		end)
Framework
function ServerFramework.Punch(mainchar, count, types)
	task.wait(.15)
	local HRP = mainchar.HumanoidRootPart
	if types == "Punch" then
		VariableModule.CreateVariable(mainchar, "DoingCombat", false, .5)
		
		local point = HRP.CFrame * CFrame.new(0,0,-3)
		local region = Hitbox.new(point, Vector3.new(3.5, 3.5, 3.5))
		local parts = region:FindPartsInRegion3WithIgnoreList({mainchar}, 100)
		
		local doing = false
		
		for i, v in pairs(parts) do
			local victim = v.Parent
			if victim ~= nil and HRP:IsDescendantOf(victim) == false and doing == false and victim:FindFirstChild("Humanoid") ~= nil and victim:FindFirstChild("HumanoidRootPart") ~= nil and victim.Humanoid.Health >0 and victim.Humanoid:GetState() ~= Enum.HumanoidStateType.Dead then
				doing = true
				if mainchar:FindFirstChild("Stun") then
					
				else
					if victim:FindFirstChild("PB") then
						victim.PB:Destroy()
						local blocking = require(Modules.BlockIndicator)
						blocking(mainchar, "Perfect Block!", Color3.new(0.0980392, 0.411765, 1), nil, Enum.Font.Arcade)
						local Anim = mainchar.Humanoid:LoadAnimation(EmiyaAnims.PB):Play(0.1, 3, 1)
						VariableModule.CreateVariable(mainchar, "Stun", false, 2)
					elseif victim:FindFirstChild("Blocking") then
						if victim.BlockHealth.Value > 0 then
							victim.BlockHealth.Value = victim.BlockHealth.Value - 10
							CombatRemote:FireAllClients(victim, 0, false, "Punch", true, "Block")
						else
							if victim:FindFirstChild("Blocking") then
								victim.Blocking:Destroy()
								VariableModule.CreateVariable(victim, "Stun", false, 3)
								CombatRemote:FireAllClients(victim, "UnBlock")
							end
							local blocking = require(Modules.BlockIndicator)
							--[[ LINE 87 ]] blocking(script.Parent, "Block Broken!", Color3.new(1, 0, 0), nil, Enum.Font.Arcade)
							if count == 6 then
								
							else
								local damage = require(Modules.DamageIndicator)
								damage(victim, 5, Color3.new(1, 0.00784314, 0.00784314),nil,Enum.Font.Arcade)
								victim.Humanoid:TakeDamage(5)
								VariableModule.CreateVariable(victim, "Stun", false, .6)
								CombatRemote:FireAllClients(victim, count, false, "Punch", true)
							end
						end
Handler
CombatRemote.OnServerEvent:Connect(function(Player, count, types)
	local char = Player.Character or Player.CharacterAdded:Wait()
	local ServerFramework = require(script:WaitForChild("ServerCombatFramework"))
	
	if not char:FindFirstChild("Stun") then
		if count == "Block" then
			if not char:FindFirstChild("DoingCombat") then
				CombatRemote:FireAllClients(char, count, types)
				ServerFramework.Block(char, count, types)
			end
		elseif count == "UnBlock" then
			CombatRemote:FireAllClients(char, count, types)
			ServerFramework.UnBlock(char, count, types)
		else
			CombatRemote:FireAllClients(char, count, types)
			--[[ LINE 26 ]] ServerFramework.Punch(char, count, types)
		end
	end
end)

On line 23, Victim:FindFirstChild("HumanoidRootPart") is nil.

But how could i fix that? I tried lots of solutions and my mind is kinda tired… x-x

Have you tried printing what Victim is to the console?

In your “BlockIndicator” on line 23 is DamageIndicator a model?

DamageIndicator appears to be a BasePart.

Either way I’m pretty sure you can’t get a CFrame from a model or a GUI.

OP is trying to retrive a CFrame from Victim's HumanoidRootPart.

Modules and BillboardGui attached to a Part
Pic1

Did you forget to parent the DamageIndicator part? (Not sure this helps with the issue, it might but this is also a big issue if you didnt)

This could be true, on 23 you’re setting the Parent of DamageIndicator to workspace. Shouldn’t it just be DamageIndicator.

Oops, didn’t see that. (limit)

Do you know if it is the Victim’s HRP that is erroring or the DamageIndicator?

oh wait i realized the issue im fairly sure, Define the Hitbox variable for me.

To be honest i even don’t know if it could be the HRP or what else… x-x

What do you mean by that? (limit)

Do you mind sending me the roblox file for the current game?

Run a test script, eg replace line 23 with

print(Victim:FindFirstChild("HumanoidRootPart"))

And i mean the Hitbox variable which is undefined for us at line 7 of “Framework”. Used as “Hitbox.new()”

After replacing line 23, print returned nil
Pic2