hi i was making a punch script the punch script's damage was value of the amount of the value of money (the money in my leaderstats) so this is what i put: local Damage = game.Players.LocalPlayer.leaderstats.strength.Value then i got this in my output: Players.TheOrizum.Backpack.Combat.RemoteEvent.Script:3: attempt to index nil with 'leaderstats' i was trying to fix it but i couldn't fix it and also heres the full script: local Combo = 0 local TimeToAttack = 1 -- time in between attacks before it resets to 0 local Damage = game.Players.LocalPlayer.leaderstats.strength.Value -- damage done to the player local Range = 7 -- Range around you

script.Parent.OnServerEvent:Connect(function(Player, EnemBlocking)

local Character = Player.Character local Humanoid = Character.Humanoid

Combo = Combo + 1

local leftPunch = Humanoid:LoadAnimation(script.leftPunch) local rightPunch = Humanoid:LoadAnimation(script.rightPunch) local leftUpperCut = Humanoid:LoadAnimation(script.leftUpperCut) local rightUpperCut = Humanoid:LoadAnimation(script.rightUpperCut)

for i,v in pairs(game.Workspace:GetChildren()) do local m = (v:IsA("Model") and v) or nil if m and m:FindFirstChild("Humanoid") and m:FindFirstChild("HumanoidRootPart") and m ~= Character then if (Character.HumanoidRootPart.Position - m.HumanoidRootPart.Position).magnitude <= Range then

			if Combo == 1 or Combo == 2 or Combo == 3 or Combo == 4 or Combo == 5 then
				m.Humanoid:TakeDamage(Damage)
			end
			
			if Combo == 1 then 
				local Punched1 = script.Punched1:Clone()
				Punched1.Parent = m.Head
				Punched1:Play()
				game.Debris:AddItem(Punched1,.4)
				m.Humanoid:LoadAnimation(script.PunchedRight):Play()
			end
			
			if Combo == 2 then 
				local Punched2 = script.Punched2:Clone()
				Punched2.Parent = m.Head
				Punched2:Play()
				game.Debris:AddItem(Punched2,.4)
				m.Humanoid:LoadAnimation(script.PunchedLeft):Play()
			end
			
			if Combo == 3 then
				local Punched3 = script.Punched3:Clone()
				Punched3.Parent = m.Head
				Punched3:Play()
				game.Debris:AddItem(Punched3,.4)
				m.Humanoid:LoadAnimation(script.rightUpperCutFace):Play()
			end
			
			if Combo == 4 then 
				local Punched4 = script.Punched4:Clone()
				Punched4.Parent = m.Head
				Punched4:Play()
				game.Debris:AddItem(Punched4,.3)
				m.Humanoid:LoadAnimation(script.leftUpperCutPunch):Play()
			end
			
			
		end
    end
end

if Combo == 1 then leftPunch:Play()

local Swing = script.SwingFist:Clone() Swing.Parent = Character.HumanoidRootPart Swing:Play()

else if Combo == 2 then rightPunch:Play()

local Swing = script.SwingFist:Clone() Swing.Parent = Character.HumanoidRootPart Swing:Play()

spawn(function() wait(TimeToAttack) if Combo == 2 then Combo = 0 end end)

else if Combo == 3 then leftUpperCut:Play()

local Swing = script.SwingFist:Clone() Swing.Parent = Character.HumanoidRootPart Swing:Play()

spawn(function() wait(TimeToAttack) if Combo == 3 then Combo = 0 end end)

else if Combo == 4 then rightUpperCut:Play()

local Swing = script.SwingFist:Clone() Swing.Parent = Character.HumanoidRootPart Swing:Play()

spawn(function() wait(TimeToAttack) if Combo == 4 then Combo = 0 end end)

Combo = 100 wait(2) Combo = 0

		end
	end
end

end

end)~~~~~~~~~~~~~~~~~

pls correct my script i started lua 1 month ago

2 comments

0

sorry if you dont understand it

1

Please put all of your code in a code block, as it makes it impossible to help you.