at line 3 I want to reach the backpack because there is a value named defe and I need that value so I can divide "d" and "Defense"
if Part.Parent:FindFirstChild("Humanoid")~= nil then local attk = script.Parent.Parent.mLevel.Value local Defense = Part.Parent.Parent.Parent.Backpack:WaitForChild("defe").Value local d = attk/Defense*7+2 local dmg = d/Defense Part.Parent.Humanoid:TakeDamage(dmg)
To reach the backpack you need to get the player, not the character. To define the player, I recommend you use :GetPlayerFromCharacter()
local player = game:GetService('Players'):GetPlayerFromCharacter(Part.Parent)
Full code:
if Part.Parent:FindFirstChild("Humanoid")~= nil then local attk = script.Parent.Parent.mLevel.Value local player = game:GetService('Players'):GetPlayerFromCharacter(Part.Parent) local Defense = player.Backpack:WaitForChild("defe").Value local d = attk/Defense*7+2 local dmg = d/Defense Part.Parent.Humanoid:TakeDamage(dmg)